写出以下程序的运行结果。#include int main(void){int i, max_sum, n, this_sum;int a[] = {-1, 3, -2, 4, -6, 1, 6, -1};scanf("%d", &n);max_sum = this_sum = 0;for( i = 0; i < n; i++ ){this_sum += a[i];if( this_sum > max_sum ) max_sum = this_sum;else if( this_sum < 0 ) this_sum = 0;}printf("%d", max_sum);return 0;}输入8,运行结果是________。输入5,运行结果是________。
查看答案
写出以下程序的运行结果。#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行输出________。