Nineth Time Assignment

Source: Internet
Author: User

#include <stdio.h>#defineN 100voidReadscore (intScore[],intn);DoubleAverageintGrade[],intn);intMaxindex (intGrade[],intn);intMinindex (intGrade[],intn);intSearchintNum[],intNintx);voidBubblesort (intGrade[],intn);voidPrintscore (intGrade[],intn);intMain () {intscore[n],n,max,min,m,num,x; DoubleAve; printf ("Please input the number of the students:\n"); scanf ("%d",&N);    Readscore (Score,n); Ave=average (score,n); Max=Maxindex (score,n); Min=Minindex (score,n); printf ("The average of the grade is%.2f,the Maxindex are%d,the minindex is%d\n", ave,max,min); printf ("Please input the grade of the student.\n"); scanf ("%d",&x); M=search (score,n,x); printf ("This students index is%d\n", M);    Bubblesort (Score,n);    Printscore (Score,n); return 0;}voidReadscore (intScore[],intN) {    inti; printf ("Please input the score:\n");  for(i=0; i<n;i++) {scanf ("%d",&Score[i]); }}DoubleAverageintScore[],intN) {    inti; Doublesum; Sum=0;  for(i=0; i<n;i++) {sum+=Score[i]; }    return(Double) sum/N;}intMaxindex (intScore[],intN) {    inti,maxindex=0;  for(i=1; i<n;i++)    {        if(score[i]>Score[maxindex]) {Maxindex=i; }    }    returnMaxindex;}intMinindex (intScore[],intN) {    inti,minindex=0;  for(i=1; i<n;i++)    {        if(score[i]<Score[minindex]) {Minindex=i; }    }    returnMinindex;}intSearchintNum[],intNintx) {    inti;  for(i=0; i<n;i++)    {        if(num[i]==x) {returni; }    }    return-1;} voidBubblesort (intScore[],intN) {    intI,j,t,flag;  for(i=0; i<n-1; i++) {flag=0;  for(j=0; j<n-1; j + +)        {            if(score[j]>score[j+1]) {T=Score[j]; SCORE[J]=score[j+1]; Score[j+1]=T; Flag=1; }        }        if(flag==0)        {             Break; }    }}voidPrintscore (intScore[],intN) {    inti;  for(i=0; i<n;i++) {printf ("%5d", Score[i]); } printf ("\ n");} 

Experimental results:

#include <stdio.h>#defineN 100intMain () {inti,num[n]={0},a=0;  for(i=0; i<n;i++) {Num[i]=i+1; }     for(i=0; i<n;i++)    {        if(num[i]%3==0|| num[i]%7==0) {Num[i]=0; }        Else{a++; printf ("%5d\n", Num[i]); }} printf ("It Remaid%d numbers", a); return  0;}

Operation Result:

This experiment summarizes:

After the experiment code is written, there are a lot of small errors, such as when using the function, after adding '; ', ' for The Loop ', ' instead of '; ',

However, the idea of the first code is quite clear and not confusing.

The second code at first did not know how to start, although the teacher said in class, but there is no idea = =. But after seeing the classmate, I understood ...

Nineth Time Assignment

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.