Item 3 Results
#include <iostream>using namespace Std;int main () {const int n=10;int score[n],a[n],b[n],max,min,j=0,k=0;double aver=0;cout<< "Please enter the scores of 10 students:"; for (int i=0;i<n;i++) {cin>>score[i];if (score[i]<0| | score[i]>100) {cout<< "score input error, please re-enter" <<endl;cin>>score[i ";}} MAX=SCORE[0];MIN=SCORE[0]; {for (i=0;i<n;i++) {if (Score[i]>max) max=score[i];if (score[i]<min) min=score[i];aver+=score[i];} for (i=0;i<n;i++) {if (Score[i]==max) {a[j++]=i;} if (score[i]==min) {b[k++]=i;}} aver=aver/n;cout<< "The group is best divided into:" <<max<<endl;cout<< "the group is divided into the lowest:" <<min<<endl;cout << "The group is divided evenly into:" <<aver<<endl; cout<< "Maximum number of people:" <<j<<endl;cout<< "minimum number of people:" <<k<<endl;cout<< "the highest score of the study number is:" for (i=0;i<j;i++) cout<<a[i]<< "";cout<<endl;cout<< "the number of the lowest score is:"; for (i=0;i<k;i++) cout <<b[i]<< ""; Cout<<endl;} return 0;}
Item four string character
#include <iostream> #include <cstdio>using namespace Std;int main () {char str[50];int i=0,n=0,j=0,k=0,x=0; cout<< "input string:"; gets (str), while (str[i]!= ') {if (str[i]>= ' 0 ' &&str[i]<= ' 9 ') {n++;i++;} else if (str[i]>= ' A ' &&str[i]<= ' Z ') {j++;i++;} else if (str[i]>= ' a ' &&str[i]<= ' Z ') {k++;i++;} else {x + +; i++;}} cout<< "Number of digits:" <<n<<endl;cout<< "number of capital letters:" <<j<<endl;cout<< "lowercase letters:" < <k<<endl;cout<< "Number of other characters:" <<x<<endl;return 0;}
Item Five summation
#include <iostream>using namespace Std;int main () {int a[10],i,sum1=0,sum2=0;cout<< "Please enter 10 numbers:"; for (i=0;i <10;i++) {cin>>a[i];if (a[i]>0) sum1+=a[i];if (a[i]<0) sum2+=a[i];} cout<< "Positive sum for:" <<sum1<<endl;cout<< "negative sum for:" <<sum2<<endl;return 0;}
C + + Job 5