举一反三
- struct abc {int a,b,c;} main() {struct abc s[2]={{1,2,3},{4,5,6}};int t; t=s[0].a+s[1].b;printf("%d ",t); }
- struct abc {int a,b,c;};main(){struct abc s[2]={{1,2,3},{4,5,6}};int t;t=s[0].a+s[1].b;printf("%d ",t); }的输出结果是( ) 。
- 写出下面程序的运行结果。struct abc{ int a; float b; char *c; }; int main(void) { struct abc x = {23,98.5,"wang"}; struct abc *px = &x; printf("%d, %s, %.1f, %s \n", x.a, x.c, (*px).b, px->c ); return 0;}
- 以下程序的运行结果是s=2,t=3#include ;using namespace std;int main(){ int s=1,t=1,a=5,b=2; if (a>;0) s++; if (a>;b) t+=s; else if (a==b) t=5; else t=2*s; cout return 0;}
- 下列程序的输出结果是 。#includeint f(int t[], int n);void main(){int a[4]={1, 2, 3, 4}, s;s=f(a, 4); printf("%d\n", s);}int f(int t[], int n){if(n>;0) return(t[n-1]+f(t,n-1));else return(0);}
内容
- 0
求s=1-1/3+1/5-1/7+…+1/13 #include main() { int p=1,n; float t=1, s=0; for(n=1; 【1】 ;n+=2) { 【2】 ; s=s+t*p; 【3】 ; } printf("s=%10.6f\n",s); }
- 1
以下程序的输出结果是 main() { int a[] = {1, 2, 3, 4}, i, x = 0; for(i = 0; i < 4; i++) { sub(a, &x); printf(“%d ”, x); } pritnf(“\n”); } sub(int *s, int *y) { static int t = 3; *y = s[t]; t--; }
- 2
下列程序的输出结果是( )。 struct abc{ int a; float b; char c[10]; } int main() { static struct abc x={23, 98.53, “wang”}; struct abc *px= &x; printf(“%d %.1f %s ”, x.a, x.b, x.c ); printf(“%d %.1f %s ”, px->a, (*px).b, px->c); printf(“%c %s”, *px->c+2,&px->c[1]); }
- 3
#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 (n>0) return t[n-1]+f(t,n-1); else return 0;} 程序运行后的输出结果是
- 4
下面程序的功能是计算1-3+5-7+ …… -99+101的值。 main() { int i,t=1,s=0; for(i=1;i<=101;i+=2) { t=______; s=s+t; t=_______; } printf("%d\n",s); }