以下程序段,在空白处填写()能使程序正确运行并输出结果。 #include <stdio.h> struct student {long num; char name[10]; char sex; float score; }; main() {struct student stu={10101,"lili",’m’,89.5},*pt; printf("%.2f",pt->score); }
A、*pt=stu;
B、pt=stu;
C、pt=&stu;
D、*pt=&stu;
第1题
在以下程序段中的空白处填写适当的表达式或语句,使程序能正确引用c数组元素。 #include <stdio.h> int main() { int c[4][5],(*p)[5],i,j,d=0; for(i=0;i<4;i++) { for(j="0;j<5;j++)" c[i][j]="d;" d++; printf("%4d",c[i][j]); } printf("\n"); p="c;" printf("%d,%d\n",____________); return 0;> A、*(p[0]+2),c[0][2]
B、*(p+1)+3,c[1][3]
C、*(p+3),c[0][3]
D、p+1,c[0][1]
第2题
A、*(p+1)
B、*p+1
C、*p[1]
D、*p+7
第3题
若能使程序运行后的输出结果如下: 201501 201502 201503 则空白处填写的表达式或语句应该是 #include <stdio.h> struct student { int age; char num[8]; }; int main() { struct student stu[3]={{20,"201501"},{21,"201502"},{19,"201503"}}; struct student *p=stu; ____________________ return 0; }
A、printf("%s\n",(*p).num); printf("%s\n",(++p)->num); printf("%s\n",stu[2].num);
B、printf("%s\n",(p++).num); printf("%s\n",(p++).num); printf("%s\n",(p++).num);
C、printf("%s\n",(++p)->num); printf("%s\n",(++p)->num); printf("%s\n",(*p).num);
D、printf("%s\n",stu[0]->num); printf("%s\n",stu[1]->num); printf("%s\n",stu[2]->num);
第4题
以下是时钟模拟显示程序,按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include <stdio.h> typedef struct clock { int hour; int minute; int second; }CLOCK; /* 函数功能:时、分、秒时间的更新 */ void Update(________) { static long m = 1; t->hour = m / 3600; t->minute = __________________; t->second = ___________; m++; if (t->hour == 24) m = 1; } /* 函数功能:时、分、秒时间的显示 */ void Display(CLOCK *t) { printf("%2d:%2d:%2d\r", t->hour, t->minute, t->second); } /* 函数功能:模拟延迟1秒的时间 */ void Delay(void) { long t; for (t=0; t<50000000; t++) { * 循环体为空语句的循环,起延时作用 } int main() long i; clock myclock; myclock.hour="myclock.minute" myclock.second="0;" for (i="0;" i++) 利用循环,控制时钟运行的时间 update(&myclock); 时钟值更新 display(__________); 时间显示 delay(); 模拟延时1秒 return 0;> A、第10行: CLOCK *t 第14行: (m – 3600 * t->hour) / 60 第15行: m % 60 第44行: &myclock
B、第10行: CLOCK *t 第14行: (m – 3600 * hour) / 60 第15行: m / 60 第44行: &myclock
C、第10行: CLOCK t 第14行: (m – 3600 * t->hour) / 60 第15行: m / 60 第44行: myclock
D、第10行: CLOCK t 第14行: (m – 3600 * hour) / 60 第15行: m % 60 第44行: myclock
第5题
A、int *p(int,int)
B、int (*p)()
C、int (*p)(int ,int);
D、其余选项都不对
第6题
A、printf("%s",(*p).num);
B、printf("%s",stu[1]->num);
C、printf("%s",(++p)->num);
D、printf("%d",p.age);
第7题
A、f
B、*f
C、(*f)
D、其余选项都不对
第8题
编写一个函数,实现一个字符串的升序排序并输出排序后的字符串,字符串长度小于20。 程序运行结果如下: Input a string: friend↙ definr 在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include <stdio.h> #include <stdlib.h> #include <string.h> #define N 20 void mySort(char str[], int n) { int i, j, tmp; if (str == NULL || n <= 0) return; for (i="0;" ________; ++i) { (_________; j n; ++j) if (____________) tmp="str[i];" str[i]="str[j];" str[j]="tmp;" } int main() char str[n]; printf("input a string:\n"); gets(str); n="_________;" mysort(str, n); printf("%s", str); return 0;> A、第10行: i < n - 1 第12行: j = i + 1 第14行: str[i] > str[j] 第30行: strlen(str)
B、第10行: i < n 第12行: j = i + 1 第14行: str[i] <= str[j] 第30行: sizeof(str)> C、第10行: i <= n 第12行: j="i" 第14行: str[i]> str[j] 第30行: strlen(str)
D、第10行: i <= 1 n - 第12行: j="n" 第14行: str[i]> str[j] 第30行: strlen(str)-1
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!