返回列表 回复 发帖

哪位大哥能帮我加颜色啊?下午检查作业

#include<stdio.h>
#include<stdio.h>
typedef struct
{ char no[10];
  char name[10];
  int eng;
  int c_pro;
  int math;
}record;
#define M 5
record stu[M],temp[M];
void getoriginaldata()
{
  int i;
  printf("\nplease input original datas:(eg:20040101 AAA 98 95 76)");
  for(i=0;i<M;i++)
  {printf("\n%dth:",i+1);
   scanf("%s%s%d%d%d",&stu[i].no,&stu[i].name,&stu[i].eng,&stu[i].c_pro,&stu[i].math);
  }
clrscr();
printf("You entered datas as follow:\n");
for(i=0;i<M;i++)
  {printf("\n%dth:",i+1);
   printf("%s,%s,%d,%d,%d",stu[i].no,stu[i].name,stu[i].eng,stu[i].c_pro,stu[i].math);
  }
printf("\n\n\tNow,Press Any Key To Continue...");
getch();
}
void notpass()
{  int i,j;
for(i=0;i<M;i++)
{
  j=0;
if(stu[i].eng<60) j+=1;
     if(stu[i].c_pro<60) j+=3;
     if(stu[i].math<60) j+=5;
     switch(i)
    { case 1:
          printf("No:%s,Course:English,Score:%d\n",stu[i].no,stu[i].eng);
     break;
      case 2:
          printf("No:%s,Course:C_Pro,Score:%d\n",stu[i].no,stu[i].c_pro);
     break;
      case 3:
          printf("No:%s,Course:Math,Score:%d\n",stu[i].no,stu[i].math);
     break;
      case 4:
          printf("No:%s,Course:English,C_Pro,Score:%d,%d\n",stu[i].no,stu[i].eng,stu[i].c_pro);
     break;
      case 5:
          printf("No:%s,Course:English,Math,Score:%d,%d\n",stu[i].no,stu[i].eng,stu[i].math);
     break;
      case 6:
          printf("No:%s,Course:C_Pro,Math,Score:%d,%d\n",stu[i].c_pro,stu[i].math);
     break;
      case 7:
   printf("No:%s,Course:English,C_Pro,Math,Score:%d,%d,%d\n",stu[i].eng,stu[i].c_pro,stu[i].math);
     break;
   }
printf("\n\n\tNow,Press Any Key To Continue...");
getch();
}
}
void courseaver()
{ int i;
  float score1,score2,score3;
    score1=score2=score3=0;
for(i=0;i<M;i++)
{ score1+=stu[i].eng;
  score2+=stu[i].c_pro;
  score3+=stu[i].math;
}
score1/=3;score2/=3;score3/=3;
printf("English,C_Pro,math Average:%f,%f,%f\n",score1,score2,score3);
printf("\n\n\tNow,Press Any Key To Continue...");
getch();
}
void courselevel()
{int i;
int ceng[5],cc_pro[5],cmath[5];
   for(i=0;i<5;i++)
   { ceng[i]=0;
     cc_pro[i]=0;
     cmath[i]=0;
    }
for(i=0;i<M;i++)
{ switch((int)stu[i].eng/10)
   {case 9:ceng[4]++;break;
    case 8:ceng[3]++;break;
    case 7:ceng[2]++;break;
    case 6:ceng[1]++;break;
    default: ceng[0]++;break;
   }
  switch((int)stu[i].c_pro/10)
   {case 9: cc_pro[4]++;break;
    case 8: cc_pro[3]++;break;
    case 7: cc_pro[2]++;break;
    case 6: cc_pro[1]++;break;
    default: cc_pro[0]++;break;
    }
   switch((int)stu[i].math/10)
    {case 9: cmath[4]++;break;
     case 8: cmath[3]++;break;
     case 7: cmath[2]++;break;
     case 6: cmath[1]++;break;
     default: cmath[0]++;break;
     }
}
printf("\n");
   
  printf("\nEnglish:90~100:%d,80~90:%d,70~79:%d,60~69:%d,0~60:%d",ceng[4],ceng[3],ceng[2],ceng[1],ceng[0]);
  printf("\nC_Pro:90~100:%d,80~90:%d,70~79:%d,60~69:%d,0~60:%d",cc_pro[4],cc_pro[3],cc_pro[2],cc_pro[1],cc_pro[0]);
  printf("\nMath:90~100:%d,80~90:%d,70~79:%d,60~69:%d,0~60:%d",cmath[4],cmath[3],cmath[2],cmath[1],cmath[0]);
printf("\n\n\tNow,Press Any Key To Continue...");
getch();
}
void display()
{
printf("\n******Welcome to use this system******\n");
printf("\n\nEnter Your Choice:\n");
printf("0.Exit\n1.Input Original Datas\n2.Caculate Everyone's Average\n3.Caculate CourseAverage\n4.Statistic Course Level\n5.Display Not Pass\n6.About Me\n");
}
void everyaver()
{ float average[M];
int i=0;
int j;
int index;
clrscr();
printf("\n\nEvery One's Average As Follow:\n");
for(j=i=0;i<M;i++,j++)
{ average[i]=(stu[i].eng+stu[i].c_pro+stu[i].math)/3;
printf("%s,%s,%d,%d,%d,\tAverage:%f\n",stu[i].no,stu[i].name,stu[i].eng,stu[i].c_pro,stu[i].math,average[i]);
}
printf("\n\n\tNow,Press Any Key To Continue...");
getch();
}
void aboutme()
{ clrscr();
printf("\n\t\tCollege Students Score Manager System");
printf("\n\t\tstuName: Wang Yandong");
printf("\n\t\tstuNO:34");
printf("\n\n\tNow,Press Any Key To Continue...");
getch();
}
main()
{ char choice;
do
{ clrscr();
display();
choice=getchar();
switch(choice)
{
case '0':printf("\n\nThank You For Using This System.\nPress Any Key To Exit...");getch();exit(0);
case '1':getoriginaldata();break;
case '2':everyaver();break;
case '3':courseaver();break;
case '4':courselevel();break;
case '5':notpass();break;
case '6':aboutme();break;
}
}while(1);
}

返回列表