C + + Job 5

Source: Internet
Author: User

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

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.