10、以下程序的功能是计算:s= 1+1/2+1/3+……+1/10, 程序运行后输出结果错误,导致错误结果的程序行是()。(如果不能凭经验看出,建议调试方法1:在循环中加入printf,输出中间结果;方法2:单行执行程序,观察运行中的变量变化)‍#include <stdio.h> int main() { int n; double s; s = 1.0; for(n=10; n>1; n--) { s = s + 1/n; } printf("%6.4f\n", s); return 0; }A.for(n=10; n>1; n--)B.s = 1.0;C.printf("%6.4f\n", s);D.s = s + 1/n;

10、以下程序的功能是计算:s= 1+1/2+1/3+……+1/10, 程序运行后输出结果错误,导致错误结果的程序行是()。(如果不能凭经验看出,建议调试方法1:在循环中加入printf,输出中间结果;方法2:单行执行程序,观察运行中的变量变化)‍#include <stdio.h> int main() { int n; double s; s = 1.0; for(n=10; n>1; n--) { s = s + 1/n; } printf("%6.4f\n", s); return 0; }

A.for(n=10; n>1; n--)

B.s = 1.0;

C.printf("%6.4f\n", s);

D.s = s + 1/n;


参考答案和解析
b=i+1 b=i+1

相关考题:

下面程序的运行结果是: 【 17 】 。#include stdio.hint f(int a[],int n){ if(n1)return a[0] + f(a+1, n-1);elsereturn a[0];}main(){ int aa[10]={1,2,3,4,5,6,7,8,9,10}, s;s = f(aa+2,4); printf("%d\n", s);}

( 33 )有以下程序#include studio.hint f ( int t[],int n ) ;main{ int a[4]={1,2,3,4},s;s=f ( a,4 ) ; printf ( " %d\n " ,s ) ;}int f ( int t[],int n ){ if ( n0 ) return t[n-1]+f ( t,n-1 ) ;else return 0 ;}程序运行后的输出结果是A ) 4B ) 10C ) 14D ) 6

34 ) 有以下程序#include stdio.hint f(int n);main(){ int a=3,s;s=f(a);s=s+f(a);printf("%d\n",s);}int f(int n){ static int a=1;n+=a++;return n;}程序运行以后的输出结果是A)7B)8C)9D)10

有以下程序#include stdio.hint fun(char s[]){ int n=0;while(*s=′9′*s=′0′) {n=10*n+*s-′0′;s++;}return(n);}main(){ char s[10]={′6′,′1′,′*′,′4′,′*′,′9′,′*′,′0′,′*′};printf("%d\n",fun(s));}程序的运行结果是A.9B.61490C.61D.5

有以下程序:includedstdio.hint f(int n); main( ){int a=3,s; s=f(a);s=s+f(a);printf(int f(int n);main( ){int a=3,s;s=f(a);s=s+f(a);printf(%dkn,s);}int f(int n){static int a=1;n+=a++;return n;}程序运行后的输出结果是( )。A.7B.8C.9D.10

以下程序运行后的输出结果是【】。includemain(){int k=1,s=0; do{ if((k%2)!=0)continue; 以下程序运行后的输出结果是【 】。include<stdio.h>main(){ int k=1,s=0;do{if((k%2)!=0) continue;s+=k; k++;}while(k>10);printf("s+%d\n",s);}

以下程序的功能是计算:。includemain(){int n; float s; s=1.0; for(n=10;n>1;n--)s=s+ 以下程序的功能是计算:。#include <stdio.h> main() { int n; float s; s=1.0; for(n=10;n>1;n--) s=s+1/n; printf("%6.4f\n",s); } 程序运行后输出结果错误,导致错误结果的程序行是( )。A.s=1.0;B.for(n=10;n>1;n--)C.s=s+1/n;D.printf("%6.4f\n",s);

要求以下程序的功能是计算main () { int n; float s; S=1.0; for (n=10; n>1; n--) s=S+1/n; printf("%6.4f\n",S); } 程序运行后输出结果错误,导致错误结果的程序行是A.s=1.0;B.for(n=10;n>1;n--)C.s=s+1/n;D.prind("%6.4f\n",s);

要求以下程序的功能是计算:s=1+1/2+1/3+…+…1/10main( ){ int n; float s;s=1.0;for(n=10;n1;n--)s=s+1/n;printf("%6.4f\n",s);}程序运行后输出结果错误,导致错误结果的程序行是A.s=1.0;B.for(n=10;n1;n--)C.s=s+1/n;D.printf("%6.4f\n",s);

下面程序的运行结果是[]。include int f(int a[],int n){ if(n>1)return a[0]+f(a+1,n-1 下面程序的运行结果是[ ]。include <stdio.h>int f(int a[],int n){ if(n>1)return a[0]+f(a+1,n-1);elsereturn a[0];}main(){int aa[10]={12,3,4,5,6,7,8,9,10},s;s=f (aa+2,4); printf("%d\n",s); }

以下程序运行后的输出结果是()。includevoid reverse(int a[],int n){int i,t;for(i=0; 以下程序运行后的输出结果是( )。 #include<stdio.h> void reverse(int a[],int n) {int i,t; for(i=0;i<n/2;i++) {t==a[i];a[i]=a[n-1-i];a[n-1-i]=t;} } main() {int b[10]={10,9,8,7,6,5,4,3,2,1};int i,s=0; reverse(b,10); for(i=0;i<3;i++)s+=b[i]; printf("%d\n",s); }A.27B.6C.25D.30

要求以下程序的功能是计算main() {int n;float s; s=1.0; for(n=10;n>1;n--) s=s+1/n; pfintf("%6.4f\n",s); } 程序运行后输出结果错误,导致错误结果的程序行是A.s=1.0;B.for(n=10;n>1;n--)C.s=s+1/n;D.printf("%6.4f\n",8);

有以下程序includeintfun(chars[]){intn=0;while(*s='0'){n=10*n+* 有以下程序 #include <stdio.h> int fun(char s[]) { int n=0; while(*s<='9'*s>='0') {n=10*n+*s-'0';s++;} return(n); } main() {char s[10]={'6','1','*','4','*','9','*','0','*'}; printf("%d\n",fun(s)); } 程序的运行结果是A.9B.61490C.61D.5

有以下程序:includeint a=2;int f(int *a){return (*a) ++;}main(){ int s=0;{ int a= 有以下程序: #include <stdio.h> int a=2; int f(int *a) { return (*a) ++;} main() { int s=0; { int a=5; s+=f(a); } s+=f(a); printf("%d\n",s) } 执行后的输出结果是( )。A.10B.9C.7D.8

以下程序运行后输入:3,abcde回车,则输出结果是【 】include move(char *str, 以下程序运行后输入:3,abcde回车,则输出结果是【 】include <string.h>move(char *str, int n){ char temp; int i;temp=str[n-1];for(i=n-1;i>0;i--) str[i]=str[i-1];str[0]=temp;}main( ){ char s[50]; int n, i, z;scanf("%d,%s",n,s);z=strlen(s);for(i=1; i<=n; i++) move(s, z);printf("%s\n",s);}

下面程序的运行结果是( )。 include main() {int a,s,n,m; a=2;s=0;n=1;m=1; while(m 下面程序的运行结果是( )。 include<stdio.h> main() {int a,s,n,m; a=2;s=0;n=1;m=1; while(m<=4){n=n*a;s=s+n;++m;} printf("s=%d",s); }

以下程序的输出结果是()。includeint fun(int n,int *s){ int f1,f2;if(n==0||n==1)*s= 以下程序的输出结果是( )。 #include<stdio.h> int fun(int n,int *s) { int f1,f2; if(n==0||n==1) *s=1; else { fun(n-1,f1); fun(n-2,f2); *s=f1+f2; } } void main() { int x; fun(6,x); printf("\n%d" ,x);}A.7B.13C.9D.10

要求以下程序的功能是计算s=1+1/2+1/3+…+1/10 main() { int n; float s; s=1.0; for(n=1O;n>1;n--) s=s+1/n; printf("%6.4f\n",s); } 程序运行后输出结果错误,导致错误结果的程序行是( )。A.s=1.0;B.for(n=1O;n>l;n--)C.s=s+1/n;D.printf("%6.4f\n",s);

有以下程序#inculde stdio.hint F(int t[],int n);main(){ int a[4]=(1,2,3,4),s;s =F(a,4);printF(“%d\n”,s);}int F(int t[],int n){ iF(n0) return t[n-1]+F(t,n-1);Else return 0;}程序运行后的输出结果是A.4B.10C.14D.6

有以下程序:includeint f(int t[],int n);main(){int a[4]={1,2,3,4},s;s=f(a,2);prin 有以下程序: #include<stdio.h> int f(int t[],int n); main() {int a[4]={1,2,3,4},s; s=f(a,2);printf("%d\n",s); } int f(int t[],int n) {if((n>0)(n<5))return t[n+1]+f(t,n-1); else return 0; } 程序运行后的输出结果是( )。A.4B.7C.10D.61

有以下程序: #includedstdio.h int f(int n); main( ) {int a=3,s; s=f(a);s=s+f(a);printf("%dkn",s); } int f(int n) {static int a=1; n+=a++; return n; } 程序运行后的输出结果是( )。A.7B.8C.9D.10

有以下程序 include int fun(char s[ ]) { int n=0; while(*s='0 有以下程序#include <stdio.h>int fun(char s[ ]){ int n=0;while(*s<='9'*s>='0') {n=10*n+*s-'0';s++;}retum(n);}main( ){ char s[10]={'6','1','*','4','*','9','*','0','*'};printf("%d\n",fun(s));}程序的运行结果是A.9B.61490C.61D.5

要求以下程序的功能是计算:s=1+1/2+1/3+…+1/100。程序运行后输出结果错误,导致错误结果的程序行是( )。A.s=1.0;B.C.S=S+1/n;D.

有以下程序: #includestdio.h int f(int t[],int n); main( ) {int a[4]={1,2,3,4},s; s=f(a,4);printf("%d\n",s); int f(int t[],int n) {if(n0)return t[n-1]+f(t,n-1); else return 0; } 程序运行后的输出结果是( )。A.4B.10C.14D.6

有以下程序:includeint fun(char s[]){ intn=0;while(*s='0'){n=10 有以下程序: #include <stdio.h> int fun(char s[]) { int n=0; while(*s<='9'*s>='0') {n=10*n+*s-'0';s++;} return(n); } main() { char s[10]={'6','1','*','4','*','9','*','0','*'}; printf("%d\n",fun(s)); } 程序的运行结果是( )。A.9B.61490C.61D.5

单选题有以下程序:#include int f(int n);main(){ int a=3,s; s=f(a); s=s+f(a); printf(%d,s);}int f(int n){ static int a=1; n+=a++; return n;}程序运行以后的输出结果是(  )。A7B8C9D10

单选题有以下程序:#include int f(int t[],int n);main(){ int a[4]={1,2,3,4},s; s=f(a,4); printf(%d,s);}int f(int t[],int n){ if(n0)return t[n-1]+f(t,n-1); else return 0;}程序运行后的输出结果是(  )。A4B10C14D6

单选题有以下程序#include int fun(char s[]){ int n=0; while(*s='0') {  n=10*n+*s-'0';  s++; } return (n);}main(){ char s[10]={'6','1','*','4','*','9','*','0','*'}; printf("%d",fun(s));}程序的运行结果是(  )。A61490B61C9D5