写出以下程序的运行结果。#include int main(void){int i, n = 5, x;int a[10] = {1, 3, 5, 7, 9};scanf("%d", &x);for (i = n-1; i >= 0; i--){if(x < a[i]) a[i+1] = a[i];else break;}a[i+1] = x;printf("%d", i+1);return 0;}输入-5,运行结果是________。输入5,运行结果是________。
查看答案
写出以下程序的运行结果。#include#includeint main(void){int i;const char *color[2] = {"blue", "green"};for(i = 0; i < 2; i++){printf("%s#%c\n", color[i], *color[i]);}for(i = 0; i < 2; i++){printf("%s#%c\n", color[i]+1, *color[i]+1);}return 0;}第1行输出________。第2行输出________。第3行输出________。第4行输出________。
以下程序运行时如果从键盘上输入字符串“qwerty”和“abcd”,则程序的输出结果是________。#include#includeint strle(char a[],char b[]){int num=0,n=0;while(*(a+num)!='\0') num++;while(b[n]){ *(a+num)=b[n];num++;n++;}return (num);}int main(void){char str1[81],str2[81],*p1=str1,*p2=str2;gets(p1);gets(p2);printf("%d",strle(p1,p2));return 0;}
写出以下程序运行结果。#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行输出________。