void main( ) { int a=0,b=0,d=0; char *s="xcbc3abcd"; for(;*s!='\0';s++); switch(*s) { case 'a':a++;break;case 'b':b++;break;default:d++;}printf("a=%d,b=%d,d=%d\n",a,b,d);}
来源:学生作业帮助网 编辑:作业帮 时间:2024/09/09 08:46:37
![void main( ) { int a=0,b=0,d=0; char *s=](/uploads/image/z/12556172-20-2.jpg?t=void+main%28+%29+%7B+int+a%3D0%2Cb%3D0%2Cd%3D0%3B+char+%2As%3D%22xcbc3abcd%22%3B+for%28%3B%2As%21%3D%27%5C0%27%3Bs%2B%2B%29%3B+switch%28%2As%29+%7B+case+%27a%27%3Aa%2B%2B%3Bbreak%3Bcase+%27b%27%3Ab%2B%2B%3Bbreak%3Bdefault%3Ad%2B%2B%3B%7Dprintf%28%22a%3D%25d%2Cb%3D%25d%2Cd%3D%25d%5Cn%22%2Ca%2Cb%2Cd%29%3B%7D)
xՑJ@_e(IVe}^AMC~z
Z)ziUznP+awY3φImIaQ@ !;h%-u d\H@:Uj6QW"h9ZL5fv
void main( ) { int a=0,b=0,d=0; char *s="xcbc3abcd"; for(;*s!='\0';s++); switch(*s) { case 'a':a++;break;case 'b':b++;break;default:d++;}printf("a=%d,b=%d,d=%d\n",a,b,d);}
void main( ) { int a=0,b=0,d=0; char *s="xcbc3abcd"; for(;*s!='\0';s++); switch(*s) { case 'a':a++;
break;
case 'b':b++;break;
default:d++;
}
printf("a=%d,b=%d,d=%d\n",a,b,d);
}
void main( ) { int a=0,b=0,d=0; char *s="xcbc3abcd"; for(;*s!='\0';s++); switch(*s) { case 'a':a++;break;case 'b':b++;break;default:d++;}printf("a=%d,b=%d,d=%d\n",a,b,d);}
结果:a=0,b=0,d=1 .
for 循环后有分好,*s 最后结果是 '\0' 所以只有 d 加 1 .
改为 for( ;*s != '\0'; s++)
printf("*s = %c\n",*s);
试试就好啦.
#include void main(){int a[30];int i;for (i=0,i
#include int a=3,b=5; max (int a,int b) {int c; c=a>b?a:b; return (c); } void main() {int
#include void main() { int a,b,c; for(a=1; a
#include void main() { int a,c; a=0; if (a
int main(void) { int k=0; while(k++
#include void main(){int i,j,a=0;for(i=0;i
九九乘法表程序#include void main(){int i,j,a;for(i=1;i
#include void main() { int a[3][3],i,j; for(i=0;i
#include void main() { int a=1 b=2 c=3 cout
#include void main() { int a,b,c,n; for(n=100;n
void Function() { printf(Call Function!
); } int main() { void (*p)(); *(int*)&p=(int)Function;
#include void main( ) { int a=3,b=5; int *p,*q; void f1(int x,int y);void f2(int *x,int *y);p=&a; q=&b;f1(*p,*q) ;printf(a=%d ,b=%d
,a,b);f2(p,q);printf(a=%d ,b=%d
,a,b);}void f1(int x,int y) { int t;t=x; x=y; y=t;}void f2(int *x,int *y) { int
void main() {int t=1;fun(fun(t));} fun(int h) {stvoid main(){int t=1;fun(fun(t));}fun(int h){static int a[3]={1,2,3}; int k; for(k=0;k
#includevoid Func(void);int main(void){int i,n;printf(
input a data:);scanf(%d,&n);for (i=0; i
void swap1(int c0[],int c1[]) { int t; t=c0[0];c0[0]=c1[0];c1[0]=t; } void swap2(int *c0,int *c1) {void swap1(int c0[],int c1[]){ int t;t=c0[0];c0[0]=c1[0];c1[0]=t;}void swap2(int *c0,int *c1){int t;t=*c0;*c0=*c1;*c1=t;}void main(){int a[2]={3,5},b[
画椭圆代码出错# include # include # include # include void MidpointEllipse(int a,int b,int color); int main() { int gdriver = DETECT,gmode=0; initgraph(500,600); MidpointEllipse(4,6,RED); getch(); closegraph(); return 0; } void MidpointE
void fun(int p) { int d=2; p=d++; printf(%d,p); } main() { int a=1; fun(a); printf(%d
,a); }
一般说函数非法定义是因为什么#include#includeconst int M=9;void main(){ void fun1(); void fun2(); int i,j,k; int a[M][M]; for(i=0;ia[i][j]; for(i=0;i