|
int n=0, i; printf("Enter mark:\n");scanf("%f",&a); while(a>=0.0&& n<1000) { sum+ 【10】 ; x[n]= 【11】 ; n++; scanf("%f",&a); } ave= 【12】 ; printf("Output:\n"); printf("ave=%f\n",ave); for (I=0;I if 【13】 printf (“%f\n”,x[I]); } (11) 有以下定义和语句,则sizeof(a)的值是 【14】 ,而sizeof(a.share)的值是 【15】 struct date{ int day; int month; int year; union{int share1 float share2; }share; }a; (12) 以下程序中用户由键盘输入一个文件名,然后输入一串字符(用#结束输入)存放到此文件文件中形成文本文件,并将字符的个数写到文件尾部,请填空。 #include main( ) { FILE *fp; char ch,fname[32]; int count=0; printf("Input the filename :"); scanf("%s",fname); if((fp=fopen( 【16】 ,"w+"))==NULL) { printf("Can't open file:%s \n",fname); exit(0);} printf("Enter data:\n"); while((ch=getchar())!="#"){ fputc(ch,fp); count++;} fprintf( 【17】 ,"\n%d\n", count); fclose(fp); } (13) 以下函数creatlist用来建立一个带头节点的单链表,链表的结构如下图所示,新的结点总是插入在链表的末尾。链表的头指针作为函数值返回,链表最后一个节点的next域放入NULL,作为链表结束标志。data为字符型数据域,next为指针域。读入时字符以#表示输入结束(#不存入链表)。请填空。 struct node { char data; struct node * next; }; . . . 【18】 creatlist( ) { struct node * h,* s,* r; char ch; h=(struct node *)malloc(sizeof(struct node)); r=h上一页 [1] [2] [3] [4] [5] [6] [7] [8] 下一页 |
|
|
|
|
|
|
|