中国大学MOOC: #include #define N (sizeof(s)/sizeof(s[0]))struct porb {char *name; int age;} s[]={"LiHua",18,"WangXin",25,"LiuGuo",21};void f(struct porb a[], int n){int i;for (i=0;i
举一反三
- 下面程序的运行结果是______。 #include<stdio.h> main() { char s[]="012xy"; int i,n=0; for(i=0;s[i]!=0;i++) if(s[i]>= 'a'&&s[i]<= 'z') n++; printf("%d\n",n); }
- 以下程序的输出结果是________。 #include "stdio.h" int f(int b[],int m,int n) { int i,s=0; for(i=m; i < = n; i=i+2) s=s+b[i]; return s; } void main() { int x,a[]={1,2,3,4,5,6,7,8,9}; x=f(a,3,7); printf("%d",x); }: 10/#/15/#/18/#/8
- 下面程序的功能是计算 S= 0!+1!+2!+…+k! ( k>=0 )。 #include "stdio.h" long fun(int n) { int i; long s=1; for(i=1; ① ;i++) s*=i; return( ② ); } int main() { int k,n; long s; scanf("%d",&n); s= ③ ; for(k=0;k<=n;k++) s+= ④ ; printf("%ld\n",s); return 0; }
- 【单选题】以下程序求数组元素平均值,请于空白处填空。 #include "stdio.h" #define N 10 int main() { int x[N],i;float s=0; printf("Enter 10 integers: "); for(i=0;i<N;i++) { scanf("%d",&x[i]); —————— } printf("av=%f ",s/N); return 0; } A. s+=x[i]; B. s=s+x(i) C. s+=x[i] D. s=s+x[i]
- 【单选题】下面程序执行后的输出结果是()。#include <stdio.h>int main(){int i=0,s=0;for (;;) {if(i==3||i==5) continue;if (i==6) break;i++; s+=i;};printf("%d",s); return 0;}#include <stdio.h>int main(){int i=0,s=0;for (;;) {if(i==3||i==5) continue;if (i==6) break;i++; s+=i;};printf("%d",s); return 0;}#include <stdio.h>int main(){int i=0,s=0;for (;;) {if(i==3||i==5) continue;if (i==6) break;i++; s+=i;};printf("%d",s); return 0;}#include <stdio.h>int main(){int i=0,s=0; A. 10 B. 13 C. 21 D. 死循环