• 130.50 KB
  • 2022-04-22 11:17:16 发布

曹计昌《C程序设计》课后习题答案.doc

  • 46页
  • 当前文档由用户上传发布,收益归属用户
  1. 1、本文档共5页,可阅读全部内容。
  2. 2、本文档内容版权归属内容提供方,所产生的收益全部归内容提供方所有。如果您对本文有版权争议,可选择认领,认领后既往收益都归您。
  3. 3、本文档由用户上传,本站不保证质量和数量令人满意,可能有诸多瑕疵,付费之前,请仔细先通过免费阅读内容等途径辨别内容交易风险。如存在严重挂羊头卖狗肉之情形,可联系本站下载客服投诉处理。
  4. 文档侵权举报电话:19940600175。
'第一章习题1.4原码:对于一个二进制数X,如果规定其最高位为符号位,其余各位为该数的绝对值,并且规定符号位值为0表示正,为1表示负,采用这种方式的二进制编码称为该二进制数X的原码。补码:正数的补码等于正数的原码,负数的补码为其原码除符号位不动外,其余各位变反再加1所得。反码:对于正数而言,反码与原码相同;对于负数而言,反码符号位的定义与原码相同,但需要将对应原码的数值位按位变反。1.5和:10101010差:000100001.6和01073  差-03371.7和0x1AABA差-0x53201.8(251)10=(11111011)2=(373)8=(FB)161.10在16位机中,[157]补=0000000010011101            [-153]补=1111111101100111157-153=157+(-153)=(0000000010011101)2+(1111111101100111)2=(0000000000000100)2=(4)101.14算法设计:用变量s存储累加和,k表示计数描述为:(1)定义变量s,k。(2)s清零,k赋初值1。 (3)判断k<101?如果是,顺序执行(4);否则转步骤(5);(4)k加到累加和变量s中,k加1;转步骤(3)。(5)输出累加和s。(6)结束。  开始结束ints=0,k=1;k<101?s=s+k;k=k+1;输出sNY1.16  第二章习题2.2(1)x,++,+,y(2)-,0xabL(3)2.89e+12L(4)”String+”FOO”” (5)x,*,*,2(6)”X??/”(7)a,?,b(8)x,--,+=,y(9)intx,=,+,10(10)”String”,“FOO” 2.3不是表识符的如下:4th首字母为数字 sizeof关键字 x*y*不是字母、数字、下划线temp-2-不是字母、数字、下划线isn’t ’不是字母、数字、下划线enum关键字 2.4合法常数:.12 0.L             1.E-5    3.F 浮点型常量2L  33333   0377UL0x9cfU 整型常量“a” “”   字符串常量‘45’             ‘’        ‘a’ 字符常量 非法常数:‘‘’必须用转义序列 0x1ag十六进制没有gE20没有尾数部分‘18’      要用八进制数‘xa’格式错误,可以是’xa’“3’4””   需要转义序列‘”’  需要转义序列 2.5(1)inta,b=5;(2)doubleh;(3)intx=2.3;0.3会被截取。(4)constlongy=1;必须赋初值(5)floata=2.5*g; g没有定义。(6)inta=b=2;在turboC中编译出错:未定义的符号’b’在main函数中。 2.6 (1)4(2)0(3)1(4)6(5)8(6)0(7)3.00(8)1 (9)108(10)0 2.7 答案不确定(1)a==b==c c未定义(2)正确(3)正确(4)正确(5)a*++-b  表达式缺值(6)a||b^i  ^运算的操作数必须是整型,而i不是(7)i*j%a %运算的操作数必须是整型,而a不是(8)正确(9)正确(10)int(a+b) 应该改成(int)(a+b) 2.9(1)0(2)-2(3)65535(4)5(5)60(6)113(7)-2(8)-1 (9)65532(10)3 2.10unsignedlongencrypt(unsignedlongx){  unsignedlongx0,x1,x2,x3,x4,x5,x6,x7;  x0=(x&0x0000000F)<<8;  x1=(x&0x000000F0);  x2=(x&0x00000F00)<<8;  x3=(x&0x0000F000);  x4=(x&0x000F0000)<<8;  x5=(x&0x00F00000);  x6=(x&0x0F000000)>>24;  x7=(x&0xF0000000);  return(x0|x1|x2|x3|x4|x5|x6|x7);} 2.11#includevoidmain(){ unsignedlongin; unsignedlonga,b,c,d;scanf("%ld",&in);//in=1563;a=(in&0xff000000)>>24;b=(in&0x00ff0000)>>16;c=(in&0x0000ff00)>>8;d=in&0x000000ff;printf("%d.%d.%d.%d",a,b,c,d);} 2.15((k>>8)&0xFF00)|((p&0x00FF)<<8) 2.16max=a>b?a>c?a:c:b>c?b:c;max=a>b?((a>c)?a:c):((b>c)?b:c); 2.17X=y>>n 2.18(c>=’0’&&c<=’9’)?c–‘0’:c 2.19 (a%3==0)&&(a%10==5)?a:0;第三章习题3.1函数原型是指对函数的名称、返回值类型、参数的数目和参数类型的说明。其规定了调用该函数的语法格式,即调用形式。putchar函数的原型为:intputchar(intc);puts函数的原型为:intputs(constchar*s);printf函数的原型为:intprintf(constchar*format,…);getchar函数的原型为:intgetchar_r(void);gets函数的原型为:char*gets_r(char*s);scanf函数的原型为:intscanf(constchar*format,…);3.2不同点:①puts为非格式输出函数,printf为格式输出函数;           ②puts函数的参数类型和数目一定(一个字符串),printf函数的参数类型和数目不固定;           ③puts函数输出后会自动换行,printf函数没有这一功能。   相同点:①二者都向标准设备输出;           ②二者返回值类型都为int。3.3x1=-1,177777,ffff,65535   x2=-3,177775,fffd,65533   y1=123.456703,  123.457,123.457,123.457 (注意对齐)   y2=123.449997,1.23450e+02,123.45   x1(%4d)= -13.4⑴%c;⑵%c;⑶%f;⑷%f;⑸%lu;⑹%d;⑺%d;⑻%d;⑼%f;⑽%Lf3.5⑴错误,运行提示为divideerror   ⑵正确,结果为b   ⑶正确,结果为        *    ⑷正确   ⑸正确,但无法正常从结果中退出   ⑹正确   ⑺正确,结果为82,63   ⑻编译错误,提示cannotmodifyaconstobject   ⑼正确   ⑽正确3.6-6.70000   -6   177601   123   -2    03.8#includevoidmain(){      charc;      c=getchar_r();      if((c>="0"&&c<="9")||(c>="A"&&c<="F")||(c>="a"&&c<="f"))      {             if((c>="0"&&c<="9"))             {                    printf("%dn",c-"0");             }              elseif((c>="A"&&c<="F"))             {             printf("%dn",c-"A"+10);             }             else             printf("%dn",c-"a"+10);      }      else             putchar(c);} 3.9#includevoidmain(){      shortnum,high,low;      printf("Pleaseinputashortnumber:n");  scanf("%hd",&num);  low=0x00ff#  high=0x00ff&(num>>8);  printf("Thehighbyteis:%cn",high);  printf("Thelowbyteis:%cn",low);   }  3.10#include"stdafx.h" intmain(intargc,char*argv[]){      unsignedshortintx;      unsignedshortinthigh,low;      printf("inputainteger:n");      scanf("%d",&x);      high=(x>>12)&0x000f;      low=(x<<12)&0xf000;      x=x&0x0ff0;      x=x|high|low;      printf("%dn",x);      return0;} 3.11 #includevoidmain(){unsignedshortintx,m,n;unsignedshortintresult; scanf("%hu%hu%hu",&x,&m,&n);result=(x>>(m-n+1))<<(15-n+1);printf("%hun",result); } 3.12#includevoidmain(){      floatf,c;      scanf("%f",&f);      c=(5*(f-32))/9;      printf("%.0f(F)=%.2f(C)n",f,c);}或者#includevoidmain(){intf;     floatc;      scanf("%d",&f);      c=(5*(f-32))/9;      printf("%d(F)=%.2f(C)n",f,c); } 3.13#include#definePI(3.1415926)intmain(intargc,char*argv[]){      doubler,h;      doubles,v;      printf("Pleaseinputtherandh.");      scanf("%lf,%lf",&r,&h);      s=2*PI*r*h+2*PI*r*r;      v=PI*r*r*h;      printf("sis%lf,vis%lf",s,v);      return0;} 3.14#include"stdafx.h" intmain(intargc,char*argv[]){            chara[4]="编";       printf("机内码:%x%xtn",a[0]&0xff,a[1]&0xff);      printf("区位码:%xtn",a[0]&0xff<<8+a[1]&0xff-0x2020-0x8080);      printf("国际码:%xtn",a[0]&0xff<<8+a[1]&0xff-0x8080);      return0;}第四章习题4.1#includevoidmain(void){floata,b,c;printf("PleaseenterthescoreofA:n");scanf("%f",&a);printf("PleaseenterthescoreofB:n");scanf("%f",&b);printf("PleaseenterthescoreofC:n");scanf("%f",&c);if((a-b)*(a-c)<0) printf("Agetsthescore%.1f",a);if((b-a)*(b-c)<0) printf("Bgetsthescore%.1f",b);if((c-a)*(c-b)<0) printf("Cgetsthescore%.1f",c);}4.3#includeintmdays(inty,intm){      if(m==2)return(y%4==0&&(y%100==0||y%400==0))?29:28;      elseif(m==4||m==6||m==9||m==11)return30;      elsereturn31;} main(){      inty,m,d,days;      printf("Enteryear:");      scanf("%d",&y);       printf("Entermonth:");      scanf("%d",&m);      printf("Enterday:");      scanf("%d",&d);      days=d;      while(m>1){days+=mdays(y,m-1);m--;}      printf("%dn",days);}4.4 if方法:#include"stdafx.h"#includeintmain(intargc,char*argv[]){      floatx=0;      printf("inputthesalaryn");      scanf("%f",&x);      if(x<0)             printf("wrongn");      elseif(x>0&&x<1000)                    printf("0n");                    elseif(x<2000)                           printf("%fn",x*0.05);                           elseif(x<3000)                                  printf("%fn",x*0.1);                                  elseif(x<4000)                                         printf("%fn",x*0.15);                                         elseif(x<5000)                                                printf("%fn",x*0.2);                                                else                                                       printf("%fn",x*0.25);      return0;} Case方法: #include"stdafx.h"#includeintmain(intargc,char*argv[]){      floatx;      printf("inputthesalaryn");      scanf("%f",&x);      intxCase=0;      xCase=(int)(x/1000.0);       switch(xCase)      {      case0:                    printf("0n");                    break;      case1:                    printf("%fn",x*0.05);                    break;      case2:                    printf("%fn",x*0.1);                    break;      case3:                    printf("%fn",x*0.15);                    break;      case4:                    printf("%fn",x*0.2);                    break;      default:                    printf("%fn",x*0.25);      }      return0;} 4.7#include"stdafx.h"#includeintmain(intargc,char*argv[]){      char*sa;      charc;      inti=0,j=0,k=0;      do      {             c=getchar_r();             sa[i++]=c;      }while(c!="r");      for(i=0;sa[i+1];i++)      {             for(j=i+1;sa[j];j++)             {                    if(sa[i]==sa[j]&&sa[j]=="")                    {                           for(k=j;sa[k];k++)                                 sa[k]=sa[k+1];                            j--;                    }             }      }      for(k=0;sa[k];k++)             printf("%2c",sa[k]);      return0;}4.8#includevoidmain(void){charc;printf("Inputthecharstobecopy:n");c=getchar();while(c!=EOF){if(c==32){c=getchar();continue;}else{putchar(c);c=getchar();}}} 4.10#include#defineEPS1e-5voidmain(){      ints=1;      floatn=1.0,t=1.0,pi=0;      while(1.0/n>=EPS)      {             pi=pi+t;             n=n+2;             s=s*(-1);             t=s/n;       }      pi=pi*4;      printf("pi=%10.6fn",pi);} 4.11#includeintmain(){      inta,b,num1,num2,temp;      printf("Inputa&b:");      scanf("%d%d",&num1,&num2);      if(num1>num2)      {             temp=num1;num1=num2;num2=temp;      }      a=num1;b=num2;      while(b!=0)      {             temp=a%b;             a=b;             b=temp;      }      printf("TheGCDof%dand%dis:%dn",num1,num2,a);      printf("TheLCMofthemis:%dn",num1*num2/a);}4.13#include"stdafx.h"#includeintPrimes(intx);//判断素数函数intmain(intargc,char*argv[]){      inti,j;      intnum;      for(num=4;num<=100;num++)      {             if(num%2==0)             {                    for(i=1;ivoidmain(void){      intc,i;      for(i=1,c=32;c<=126;++i,++c)      {                          printf("%3d%-5c",c,c);             if(!(i%8))               printf("n");      }}4.18#include"stdafx.h"#includeintmain(intargc,char*argv[]){       intx;      inti,n,sum;      printf("input10numbersn");      for(i=0,n=0,sum=0;i<10;i++)      {             scanf("%d",&x);             if(x>0)             {                    sum+=x;                    n++;             }      }      if(n)             printf("numbers=%d,average=%fn",n,1.0*sum/n);      return0;} 第五章习题5.5Extern和static存储类型的区别:Static型外部变量和extern型外部变量的唯一区别是作用域的限制。静态外部变量只能作用于定义它的文件,其他文件中的函数不能使用。Extern型外部变量的作用域可以扩大到整个程序的所有文件。Static和auto存储类型的区别:静态局部变量和自动变量有根本性的区别。由于静态局部变量在程序执行期间不会消失,因此,它的值有连续性。当退出块时,它的值能保存下来,以便再次进入块时使用,而自动变量的值在退出块时都丢失了。如果定义时静态局部变量有显示初始化,只在第一次进入时执行一次赋初值操作,而自动变量每次进入时都要执行赋初值操作。5.6不能。在C语言中,参数的传递方式是“值传递”,即把实参的值拷贝到参数的存储区中。因此,swap()函数交换的只是实参的本地拷贝,代表swap()实参的变量并没有被改变。5.7 6,125.10 #includedoublesum_fac(intn){  doubles=0;  inti;  doublefac=1.0;  for(i=1;i<=n;i++)  {    fac*=1.0/i;     s+=fac;  }  returns;}voidmain(void){  intn;  printf("Pleaseentertheintegern:");  scanf("%d",&n);   printf("thesumis%lfn",sum_fac(n));}5.17#includevoidreverse(){      charch=getchar_r();      if(ch!="n")      {             reverse();             putchar(ch);      }}intmain(){      reverse();      printf("n");   return0;} 第六章习题6.1(1)正确(2)错误,不需要加“;”(3)错误,“ident”与“(”之间不能有空格(4)错误,宏名不能是关键字“void”(5)错误,将x*y改成((x)*(y)) 6.4将会导致变量blue的重复定义 6.5(1)#defineNO0 (2)#include“common.h”(3)#line3000(4)#undefTRUE #defineTRUE1(5)#ifTRUE!=0#defineFALSE0#else #defineFALSE1#endif(6)#ifndefSIZE    assert(0);#elseassert(SIZE<10&&SIZE>1);#endif(7)#defineSQUARE_VOLUME(x)(x)*(x)*(x) 6.10#include#definepi3.1415926#defineBALL_VOLUME(r) ((4/3)*pi*(r)*(r)*(r))intmain(){intr;floatv[11];for(r=1;r<11;r++){v[r]=float(BALL_VOLUME(r));printf("r=%2d     v=%.2fn",r,v[r]);}return0;}第七章习题7.9#include#include#defineg10voidmain(){char*buffer;intgdriver=DETECT,gmode,i,size; initgraph(&gdriver,&gmode,"c:\tc\bgi");setbkcolor(BLUE);setcolor(RED);setlinestyle(0,0,1);setfillstyle(1,5);circle(200,250,RED);size=imagesize(200,250,200,300);buffer=malloc(size);getimage_r(200,250,200,300,buffer);for(i=0;i<=10;i++)putimage(200,250+g*i*i/2,buffer,COPY_PUT);getch_r();closegraph();} 7.11#include#defineRAND_MAX32767#defineRAND  100intRandomInteger(intlow,inthigh) {   intk;   doubled;   d=(double)rand()/((double)RAND_MAX+1);   k=(int)(d*(high-low+1));   return(low+k);}voidmain(){longi;intn=0;intszWord[RAND];chara[]="heads";charb[]="tails";srand(time(0));for(i=0;i2000){For(i=2000;imonth;i--)Total+=(MonthDays(i,1999));Return((13-total%7)%7);}Else{For(i=1999;imonth;i--)Total+=(MonthDays(i,year); Return((13-total%7)%7);}} intIsLeapYear(intyear){Return(!((year%4)&&(year%400))||!(year%400));}  #include#include“caltools.h”Voidmain(){Intmonth,year;Printf(“pleaseinputthemonthandyear:”);Scanf(“%d%d”,&month,&year);Printf(“thenameofthemonthis%sn”,MonthName(month));Printf(“thereare%ddaysinthismonth.n”,MonthDays(month,intyear));Printf(“thefirstdayofthemonthinthisyearis%d”,FirstDayOfMonth(month,year));} 第八章习题8.4#include"stdafx.h"#include"malloc.h"#defineN65535 voidDelSpace(charsa[]);intmain(intargc,char*argv[]){      charsa[N];      charc;      inti=0;      do      {             c=getchar_r();             if(c==13)             sa[i++]="n";             else             sa[i++]=c;      }while(c!="@");    DelSpace(sa);      intj=0;      while(1)      {      if(sa[j]=="@")             break;      printf("%c",sa[j++]);      }      printf("/n");      return0;} voidDelSpace(charsa[]){      char*t1=(char*)malloc(sizeof(sa));      char*t2=(char*)malloc(sizeof(sa));      t1=t2=sa;       while(*t1)                {              *t2++=*t1++;                if(*(t2-1)==""&&*t1=="")                t2--;           }          }还有一个方法:voidDelSpace(charsa[],intn){      char*tmpbuf=(char*)malloc(sizeof(sa)+1);      intp1=0,p2=0;      boolbSpace=false;      while(p1=0)             printf("name:%sscore:%dn",stu[ifind].name,stu[ifind].mark);      else             printf("NotFind");      return0;} voidscoreSort(stuInfo*stu,intn)//n为学生数{      for(inti=0;istu[mid].mark)             {                    i=mid+1;             }             else                     returnmid;      }      return-1;}    8.11#include"stdafx.h"#include"malloc.h"int*strnins(char*s,char*t,intn);intmain(intargc,char*argv[]){      char*s="abcd";      char*t="ttt";      intn=2;       strnins(s,t,n);            return0;} int*strnins(char*s,char*t,intn){      char*p=(char*)malloc(sizeof(s)-1);      inttlong =0;//字符串t的长度      while(t[tlong]!="")      {             tlong++;      }      inti=n;      intj=0;      while(jvoidhalf(intx);voidmain(){intx;printf("pleaseinputaninterer:n");scanf("%d",&x);half(x);}voidhalf(intx){intk;char*p;charup_half,low_half;p=(char*)&x;p=p+1;for(k=1;k>=0;k--){low_half=(*p)&0x0f;if(low_half<10)low_half|="0";else low_half=(low_half-10)+"A";up_half=(*p>>4)&0x0f;if(up_half<10)up_half|="0";elseup_half=(up_half-10)+"A";p--;printf("%c%cn",up_half,low_half);}}9.3#includevoidchachen(int*x,int*y);main(){inta[3],b[3];int*x,*y,i;x=&a[0];y=&b[0];printf("pleaseinput3numbersofvectorx:n");scanf("%d%d%d",x,x+1,x+2);printf("pleaseinput3numbersofvectory:n");scanf("%d%d%d",y,y+1,y+2);chachen(x,y);} voidchachen(int*x,int*y){inti,j,a,b,c;intk="i";int*pz,z[3][3];pz=&z[0][0];for(i=0,j=0;j<3;j++){*(pz+3*i+j)=k++;}for(i=1,j=0;j<3;j++){*(pz+3*i+j)=*(x+j);}for(i=2,j=0;j<3;j++){*(pz+3*i+j)=*(y+j);} a=(*(pz+3*1+1))*(*(pz+3*2+2))-(*(pz+3*1+2))*(*(pz+3*2+1));b=(*(pz+3*1+0))*(*(pz+3*2+2))-(*(pz+3*1+2))*(*(pz+3*2+0));c=(*(pz+3*1+0))*(*(pz+3*2+1))-(*(pz+3*1+1))*(*(pz+3*2+0)); printf("thejuzhenzis:n");for(i=0,j=0;j<3;j++)printf("%3c",*(pz+3*i+j));printf("n");for(i=1;i<3;i++) {for(j=0;j<3;j++)printf("%3d",*(pz+3*i+j));printf("n");}printf("theresultis:(%d)i+(%d)j+(%d)k",a,b,c);}  9.5(用指针做)#include#defineN5voidreverse(inta[],intn){inti,k,t;int*p,*q;p=&a[0];q=&a[4];for(i=0;i#defineN5voidreverse(inta[],intn){      inti,temp;      for(i=0;ivoidmain(){intx[5][5];inti,j;int*p=&x[0][0];for(i=0;i<5;i++){printf("pleaseinputline%dofthe5*5matrix:n",i+1);for(j=0;j<5;j++)scanf("%d",p+j+5*i);}printf("thetransposeofthe5*5matrixis:n");for(i=0;i<5;i++){for(j=0;j<5;j++)printf("%d",p+5*j+i);printf("n");  }}9.10voidstrcat(char*t,char*s){inti=0,j=0;while(*(t+i)!=’’)i++;while(*(s+j)!=’0’){*(t+j)=*(s+j);i++;j++;}} 第十章习题10.4#include#includestructpoint{intx,y,z;};structline{structpointstart;structpointend;}; doubledistance(structline);main(){structlinea={{1,1,1},{2,2,2}};doublelength;printf(“pleaseinputthepositionofthestartingpoints”);scanf(“%d%d%d”,&a.start.x,&a.start.y,&a.start.z);printf(“pleaseinputthepositionoftheendingpoints”);scanf(“%d%d%d”,&a.end.x,&a.end.y,&a.end.z);length=distance(a);printf(“thedistanceofthetwopointsis%f”,length);}doubledistance(structlinem){return(sqrt((m.start.x-m.end.x)*(m.start.x-m.end.x)+(m.start.y-m.end.y)*(m.start.y-m.end.y)+(m.start.z-m. end.z)*(m.start.z-m.end.z)));} 10.6#include#includestructpoint{intx,y,z;};structline{structpointstart;structpointend;}; doubledistance(structline);structlineextenddistance(structline,int);main(){structlinea={{1,1,1},{2,2,2}};structlinechangeline;doublelength;intk;printf("pleaseinputthepositionofthestartingpoints");scanf("%d%d%d",&a.start.x,&a.start.y,&a.start.z);printf("pleaseinputthepositionoftheendingpoints");scanf("%d%d%d",&a.end.x,&a.end.y,&a.end.z);length=distance(a);printf("thedistanceofthetwopointsis%fn",length);printf("inputthevalueofthekn");scanf("%d",&k);changeline=extenddistance(a,k);printf("thenewpositionoftheendingpointsis%d,%d,%dn",changeline.end.x,changeline.end.y,changeline.end.z);}doubledistance(structlinem){return(sqrt((m.start.x-m.end.x)*(m.start.x-m.end.x)+(m.start.y-m.end.y)*(m.start.y-m.end.y)+(m.start.z-m.end.z)*(m.start.z-m.end.z)));}structlineextenddistance(structlinem,intn){doubleextendlength;structliney;extendlength=n*distance(m); y.start.x=m.start.x;y.start.y=m.start.y;y.start.z=m.start.z;y.end.x=n*m.end.x+(1-n)*m.start.x;y.end.y=n*m.end.y+(1-n)*m.start.y;y.end.z=n*m.end.z+(1-n)*m.start.z;return(y); } 10.10 #include#includestructstu_study{charnum[10];charname[10];intmath;intenglish;intchinese;};scan(structstu_studystudent[]);print(structstu_studystudent[]);modify(structstu_study*student);float*aver_score(structstu_studystudent[],floatscores[]);sort(structstu_studystudent[],floatscores[]);main(){inti,m;floatscores[6];structstu_studystudent[6];scan(student);print(student);printf("whichstudent"sinformationdoyouwanttomodify?n");scanf("%d",&i);modify(&student[i]);print(student);aver_score(student,scores);for(m=1;m<6;m++){printf("theaveragescoreofstudent%dis%.2fn",m,scores[m]);}sort(student,scores);for(i=1;i<6;i++){printf("%s%s%d%d%d %.2fn",student[i].num,student[i].name,student[i].math,student[i].english,student[i].chinese,scores[i]);}}scan(structstu_studystudent[]){inti;printf("pleaseinputtheinformationofthefivestudentsn");for(i=1;i<6;i++){printf("pleaseinputtheinformationofthestudent%dn",i);scanf("%s%s%d%d%d",&student[i].num,&student[i].name,&student[i].math,&student[i].english,&student[i].chinese);}}print(structstu_studystudent[]){inti;printf("pleaseoutputtheinformationofthefivestudentsn");for(i=1;i<6;i++){printf("theinformationofstudent%d:n",i);printf("%s%s%d%d%dn",student[i].num,student[i].name,student[i].math,student[i].english,student[i].chinese);}} modify(structstu_study*student){intitem;printf("whichitemdouyouwanttomodify?n");scanf("%d",&item);switch(item){case1:              printf("pleaseinputthenewnumber:n");              scanf("%s",student->num);              printf("modifysucessfully,thenewnumberis%sn",student->num);break;case2:              printf("pleaseinputthenewname:n");              scanf("%s",student->name);              printf("modifysucessfully,thenewnumberis%sn",student->name);break;case3:              printf("pleaseinputthenewscoreofmath:n");               scanf("%d",student->math);              printf("modifysucessfully,thenewnumberis%sn",student->math);break;case4:              printf("pleaseinputthenewscoreofenglish:n");              scanf("%d",student->english);              printf("modifysucessfully,thenewnumberis%sn",student->english);break;case5:              printf("pleaseinputthenewscoreofchinese:n");              scanf("%d",student->chinese);              printf("modifysucessfully,thenewnumberis%sn",student->chinese);        break;default:        printf("inputerror!");}} float*aver_score(structstu_studystudent[],floatscores[]){inti;for(i=1;i<6;i++){scores[i]=(student[i].math+student[i].english+student[i].chinese)/3;}returnscores;}sort(structstu_studystudent[],floatscores[]){inti,j,t,k,m;floats_scores[6];for(m=1;m<6;m++){s_scores[m]=scores[m];}for(i=1;i<5;i++){for(j=1;j<6-i;j++)if(s_scores[j]#include structstu_list{charnum[10];charname[10];intmath;intenglish;intchinese;floatscores;structstu_list*next;};structlist*head;voidscan();voidprint();voidmodify();voidaver_score();voidsort();main(){inti=0;intm,n;structstu_list*p,*q;scan();print();modify();print();aver_score();p=head->next;for(m=1;m<6;m++){printf("theaveragescoreofstudent%dis%.2fn",m,p->scores);p=p->next;}sort();q=head->next;for(i=1;i<6;i++){if(q->scores>60.0&&q->scores<70.0)printf("%s%s%d%d%d%.2fn",q->num,q->name,q->math,q->english,q->chinese,q->scores);q=q->next;} }voidscan(){inti;structstu_list*p,*q; p=(structlist*)malloc(sizeof(structstu_list));p->next=NULL;head=p;q=p;printf("pleaseinputtheinformationofthefivestudentsn");for(i=1;i<6;i++){p=(structlist*)malloc(sizeof(structstu_list));printf("pleaseinputtheinformationofthestudent%dn",i);scanf("%s%s%d%d%d",&p->num,&p->name,&p->math,&p->english,&p->chinese);q->next=p;q=p;}}voidprint(){inti;structstu_list*p,*q;p=head->next;printf("pleaseoutputtheinformationofthefivestudentsn");for(i=1;i<6;i++){printf("theinformationofstudent%d:n",i);printf("%s%s%d%d%dn",p->num,p->name,p->math,p->english,p->chinese);p=p->next; }}voidmodify(){intn,item;inti=0;structstu_list*p;printf("whichstudent"sinformationdoyouwanttomodify?n");scanf("%d",&n);printf("whichitemdouyouwanttomodify?n");scanf("%d",&item);p=head;while(inext;i++;}switch(item){ case1:              printf("pleaseinputthenewnumber:n");              scanf("%s",p->num);              printf("modifysucessfully,thenewnumberis%sn",p->num);break;case2:              printf("pleaseinputthenewname:n");              scanf("%s",p->name);              printf("modifysucessfully,thenewnumberis%sn",p->name);break;case3:              printf("pleaseinputthenewscoreofmath:n");              scanf("%d",p->math);              printf("modifysucessfully,thenewnumberis%sn",p->math);break;case4:              printf("pleaseinputthenewscoreofenglish:n");              scanf("%d",p->english);              printf("modifysucessfully,thenewnumberis%sn",p->english);break;case5:              printf("pleaseinputthenewscoreofchinese:n");              scanf("%d",p->chinese);              printf("modifysucessfully,thenewnumberis%sn",p->chinese);        break;default:        printf("inputerror!");}} voidaver_score(){inti;structstu_list*p;floatm;p=head->next;for(i=1;i<6;i++){p->scores=(p->math+p->english+p->chinese)/3;p=p->next;}} voidsort() {inti,j,m,k,t;floats_scores[6];structstu_list*p;p=head->next;for(m=1;m<6;m++){s_scores[m]=p->scores;p=p->next;}for(i=1;i<5;i++){for(j=1;j<6-i;j++)if(s_scores[j]structlist{char data;structlist*next;}main(){structlist*head=NULL,*tail,*p;charc,b;c=getchar_r();head=(structlist*)malloc(sizeof(structlist));head->data=c;tail=head;while((c=getchar_r())!=EOF){tail->next=(structlist*)malloc(sizeof(structlist));tail=tail->next;tail->data=c;}tail->next=NULL;p=head; while(p){ printf("%ct",p->data);p=p->next;}printf("n");}'