写出以下程序运行结果。#include struct st{char c;char s[80];};struct st a[4] = {{'1',"123"}, {'2',"321"}, {'3',"123"}, {'4',"321"}};char * f(struct st *t);int main(void){int k;for(k = 0; k < 4; k++){printf("%s\n", f(a+k));}return 0;}char * f(struct st *t){int k = 0;while(t->s[k] != '\0'){if( t->s[k] == t->c){return t->s+k;}k++;}return t->s;}第1行输出________。第2行输出________。第3行输出________。第4行输出________。
查看答案
写出以下程序的运行结果。#include struct STU{char name[10];int num;};void f(struct STU stu[],char *name,int num){int i;struct STU s[2]= {{"Sun",202004},{"Peng",202005}};for(i=0; i<2; i++){num=s[i].num;strcpy(name,s[i].name);}}int main(void){int i;struct STU s[2]= {{"Yang",202002},{"Li",202003}},*p;for(i=0;i<2;i++){printf("%s#%d\n",s[i].name,s[i].num);}p=s;printf("%s#%d\n",p->name,p->num);f(s,p->name,p->num);printf("%s#%d\n",p->name,p->num);return 0;}第1行输出________。第2行输出________。第3行输出________。第4行输出________。
写出以下程序的运行结果。#include #define MAXM 6#define MAXN 6int main(){int i, j, m, n, sum;int a[MAXM][MAXN];scanf("%d %d", &m, &n);for (i = 0; i < m; i++){for (j = 0; j < n; j++){scanf("%d", &a[i][j]);}}for (j = 0; j < n; j++){sum = 0;for (i = 0; i < m; i++){sum += a[i][j];}printf("%d\n", sum);}return 0;}运行程序时输入3 26 31 -83 12第1行输出______。第2行输出______。
写出以下程序的运行结果。#include#define MAXN 100struct student{char name[20];int score;char grade;};void set_grade( struct student *p, int n );int main(){int i, n;struct student stu[MAXN];scanf("%d", &n);for(i = 0; i < n; i++){scanf("%s%d", stu[i].name, &stu[i].score);}set_grade(stu, n);for(i = 0; i < n; i++)printf("%s#%c\n", stu[i].name, stu[i].grade);return 0;}void set_grade(struct student *p, int n){struct student *q = p + n - 1;while(p <= q ){if ( p->score >= 60 )p->grade = 'P';elsep->grade = 'F';p++;}}运行程序时输入4zhao 60liu 75li 53wang 96第1行输出______。第2行输出______。第3行输出______。第4行输出______。
运行以下程序,输入5个数字,分别是1 3 5 7 9,写出程序的运行结果。#includeint main(void){const int n=5;int i;double average, sum;int a[n];printf("Enter %d integers: ",n);sum = 0;for(i =0; iaverage:");for(i = 0; i average)printf("%d ", a[i]);}printf("\n");return 0;}