C + + job 5, array separation, score, array selection

Source: Internet
Author: User

#include <iostream>using namespace Std;int main () {int a[10]={1,2,3,4,5,6,7,8,9,10},b[10],c[10],i=0,j=0,k=0; for (i=0;i<10;i++) {if (a[i]%2!=0) {b[j]=a[i];cout<< "Odd Group is" <<b[j]<<endl;j++;} else {c[k]=a[i];cout<< "Even group is" <<c[k]<<endl;                        k++;}} return 0;}

#include <iostream>using namespace Std;int main () {int a[10],i=0,max=0,min=0,sum=0,j=0,k=1,m=0,n=0;double average=0;cout<< "Please enter the scores of 10 students (between 0 and 100)" <<endl;for (i=0;i<10;i++) {cin>>a[i];} Max=a[0];min=a[0];for (i=1;i<10;i++) {if (A[i]>max) max=a[i];if (a[i]<min) min=a[i];} cout<< "The highest score for the" <<max<<endl;cout<< "score is lowest for" <<min<<endl;for (i=1;i<10;i++) { if (Max==a[i]) {j=j+1;m=i;} cout<< "The numbers of the students with the highest score are" <<M<<ENDL;} for (i=1;i<10;i++) {if (Min==a[i]) {k++;n=i;} cout<< "The numbers of the students with the highest score are" <<M<<ENDL;} cout<< "The students with the highest score" <<j<< "<<endl;cout<<" score the lowest students have "<<k<<" <<endl; for (i=0;i<10;i++) {sum=sum+a[i];} average=sum/10.0;cout<< "mean value" <<average<<endl;        return 0;}


#include <iostream>using namespace Std;int main () {int a[10]={1,2,3,3,5,6,7,8,9,10},i=0;cout<< defined initial array a[ 10]={1,2,3,3,5,6,7,8,9,10} "<<endl;cout<<" The new Array is "<<endl;for (i=0;i<10;i++) {if (a[i]==3) {for (i =2;i<9;i++) a[i]=a[i+2];}} for (i=0;i<8;i++) {cout<<a[i];} return 0;}



C + + job 5, array separation, score, array selection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.