C + + Job five

Source: Internet
Author: User

First, the results

#include <iostream.h>void main () {Double Ave;    int score[10],i,max,min,sum=0,a=0,b=0;      cout<< "Please input the results of group students" <<endl;      for (i=0;i<10;i++) cin>>score[i];      MAX=SCORE[0];              for (i=1;i<9;i++) if (Max<score[i]) max=score[i];for (i=1;i<9;i++) if (Max==score[i])            a++;      {min=score[0];              for (i=1;i<10;i++) sum=sum+score[i];      if (Min<score[i]) min=score[i];                for (i=1;i<10;i++) if (score[i]==min) b++;          ave=sum/10.0; } cout<< "This group has the highest score of" <<max<< "\ n" << "total" <<a<< "person" << "study number" <<a<<          Endl cout<< "Minimum score for this group is" <<min<< "\ n" << "total" <<b<< "person" << "study number" <<b<<endl          ;  cout<< "Average score" <<ave<<endl; }

Two, string

#include <iostream>    #include <cstdio>    using namespace std;    int main ()    {        char a[50];        int i=0,a=0,b=0,c=0;        cout<< "Please enter string" <<endl;        Gets (a);        while (a[i]!= ')        {            if (a[i]>= ' 0 ' &&a[i]<= ' 9 ')                a++;            else if ((a[i]>= ' a ' &&a[i]<= ' z ') | | (a[i]>= ' A ' &&a[i]<= ' Z '))                b++;            else                C + +;            i++;        }        cout<< "Number of numbers is:" <<a<<endl;        cout<< "Number of letters:" <<b<<endl;        cout<< "Number of other characters:" <<c<<endl;        return 0;    }   

Three, array separation


#include <iostream.h>  void Main ()  {      int a[10],b[10]={0},c[10]={0},i,j,k;cout<< "Please enter 10 numbers" <<endl;    for (i=0;i<10;i++)          cin>>a[i];      for (i=0,j=0,k=0;i<10;i++)      {          if (a[i]%2)              b[j++]=a[i];          else c[k++]=a[i];      }      for (i=0;i<j;i++)          cout<< "Odd is" <<b[i]<< ' \ t ';      cout<<endl;      for (i=0;i<k;i++)          cout<< "Even is" <<c[i]<< ' \ t ';      cout<<endl;  }  



C + + Job five

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.