C + + Job 5

Source: Internet
Author: User

"Item 2: Array Selection"

#include <iostream.h>void main () {const int n=10;int a[n],b[n],j=0,k=0,t=0;cout<< "Please enter" <<N<< " Number: "; for (int i=0;i<n;i++) {cin>>a[i];} for (i=0;i<n;i++) {for (j=0;j<n;j++) {if (a[i]!=a[j]) k++;} if (k==n-1) {b[t]=a[i];t++;} k=0;} The values in the cout<< "B array are:"; for (i=0;i<t;i++) {cout<<b[i]<< "";} Cout<<endl;}


"Item 3: Achievements"

#include <iostream.h>void main () {const int n=10;int a=0,b=0; Double score[n],score1[n],score2[n];cout<< "Please enter Group" <<N<< "Students ' scores:" <<endl;for (int i=0;i<n ; i++) {Cin>>score[i];if (score[i]>100| | score[i]<0) cout<< "score error, please re-enter";} cout<< "Statistical results are as follows:" <<endl;double max,min,aver;max=min=aver=score[0];for (i=0;i<n;i++) {aver+=score[i]; if (Score[i]>max) Max=score[i];else if (score[i]<min) min=score[i];} aver=aver/n;cout<< "The highest score is:" <<max<<endl;cout<< "minimum score is:" <<min<<endl;cout< < "average score is:" <<aver<<endl;for (i=0;i<n;i++) {if (Score[i]==max) {score1[a]=i;a++;} if (score[i]==min) {score2[b]=i;b++;}} cout<< "The highest scores of students have" <<a<< ", is"; for (i=0;i<a;i++) {cout<<score1[i]+1<< "classmate"; if (i< A-1) cout<< "and";} cout<<endl;cout<< "The lowest grade students have" <<b<< "bit, is"; for (i=0;i<b;i++) {cout<<score2[i]+1< < "classmate"; if (i<b-1) cout<< "and";} Cout<<endl;}

"Item 5: Summation"

#include <iostream.h>void main () {const int n=10;int a[n],j=0,k=0,t=0;cout<< "Please enter" <<N<< "number:"; for (int i=0;i<n;i++) {cin>>a[i];} for (i=0;i<n;i++) {if (a[i]>=0) j+=a[i];elsek+=a[i];} The sum of the positive numbers in the cout<< array is: the sum of the negative numbers in the <<j<<endl;cout<< array: "<<K<<ENDL;}


C + + Job 5

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.