【单选题】以下程序求数组元素平均值,请于空白处填空。 #include "stdio.h" #define N 10 int main() { int x[N],i;float s=0; printf("Enter 10 integers:
"); for(i=0;i",s/N); return 0; }
A. s+=x[i]; B. s=s+x(i) C. s+=x[i] D. s=s+x[i]
"); for(i=0;i
A. s+=x[i]; B. s=s+x(i) C. s+=x[i] D. s=s+x[i]
举一反三
- 下列程序段可以正确运行的有: A: int i,s,x;s=0;i=0;while(1){ scanf("%d",&x); if(x!=-1) { s=s+x; i++; } else break;}printf("ave=%d\n",s/i); B: int i,s,x;s=0;i=0;scanf("%d",&x);while(x!=-1){ s=s+x; i++; scanf("%d",&x);}printf("ave=%d\n",s/i); C: int i,s,x;s=0;i=0;while(1){ scanf("%d",&x); if(x==-1) break; s=s+x; i++; }printf("ave=%d\n",s/i);
- 以下程序的输出结果是________。 #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
- 【单选题】下面程序执行后的输出结果是()。#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. 死循环
- *【程序填空】题目:从键盘输入10个数,求平均值。*/ #include "stdio.h" main( ) { /***********SPACE***********/ int x,i,【?】; /***********SPACE***********/ 【?】 ave; i=1; /***********SPACE***********/ while(【?】) { scanf("%d",&x); s=s+x; i++; } ave=s/10.0; /***********SPACE***********/ printf("%f\n",【?】); }
- 中国大学MOOC: 下面程序执行后的输出结果是( )。#include 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 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 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 int main(){ int i=0,s=0; for (;;) { if(i==3||i==5) continue;