- #include
-
- int main()
- {
- int c;
- c=x+y;
- printf("%d",c);
-
- return 0;
- }
- #include
-
- int main()
- {
- int c;
- c=6+3;
- printf("%f",c);
-
- return 0;
- }
结果是0.000000
- #include
-
- int main()
- {
- int c;
- c=20000000000;
- printf("%d",c);
-
- return 0;
- }
结果
- -1474836480
- --------------------------------
- Process exited after 0.4559 seconds with return value 0
- 请按任意键继续. . .
- #include
-
- int main()
- {
- int c;
- scanf("%d",c);
- printf("%d",c);
- int *p=&c;
- scanf("%d",&p);
- printf("%d",*p);
-
- return 0;
- }
结果
- 45
-
- --------------------------------
- Process exited after 2.355 seconds with return value 3221225477
- 请按任意键继续. . .
-
- #include
-
- int main()
- {
- int c,b;
- scanf("%d%d",&c,&b);
- printf("%d%d",c,b);
-
-
- return 0;
- }
结果
- 2,3
- 21
- --------------------------------
- Process exited after 3.381 seconds with return value 0
- 请按任意键继续. . .
- #include
-
- int main()
- {
- char arr[20];
- scanf("%s",&arr);//不需要取地址,多余
- puts(arr);
- int arr_1[20];
- scanf("%d",arr_1);//数值赋值只能循环单个赋值
-
-
-
- return 0;
- }
#include ;
- #include
-
- int main()
- {
- int arr_1[20];
- int i;
- for(i=0;i<5;i++);
- {
- scanf("%d",&arr_1[i]);//数值赋值只能循环单个赋值
- }
- if(arr_1[2]>0);
- {
- printf("%d",arr_1[2]);
- }
- switch(i);
- {
- ...;
- }
-
-
- return 0;
- }
- #include
-
- int main()
- {
- int arr_1[20];
- int i;
- for(i=0;i<5;i++);
- {
- scanf("%d",&arr_1[i]);//数值赋值只能循环单个赋值
- }
- if(arr_1[2]>0);
- {
- printf("%d",arr_1[2]);
-
- switch(i);
- {
- ...;
- }
-
-
- return 0;
- }
- while((c=getchar()==0)
- {
- ...;
- }
- #include
-
- int main()
- {
- int arr_1[20];
- int i;
- for(I=0;I<5;I++)
- {
- scanf("%d",&arr_1[I]);//数值赋值只能循环单个赋值
- }
-
-
- return 0;
- }
- if(arr_1[2]=1)
- {
- ...;
- }
- #include
-
- int main()
- {
- int arr_1[20];
- int i;
- for(i=0;i<5;i++)
- {
- scanf("%d",&arr_1[i]);//数值赋值只能循环单个赋值
- }
- printf("%d",arr_1[20]);//越界
-
- return 0;
- }
- #include
-
- int main()
- {
- int arr_1[20];
- int i;
- for(i=0;i<5;i++)
- {
- scanf("%d",&arr_1[i]);//数值赋值只能循环单个赋值
- }
- printf("%d",arr_1[20]);//越界
- int b[20];
- b=arr_1;//错误
- return 0;
- }
- #include
-
- int main()
- {
- char a[]="shanshanerchuan";
- a="buyaneryu";//错误
- char *b="wohewodezuguo";
- b="woshibushinizuitengaideren"; //可以
- return 0;
- }
- #include
-
- int main()
- {
- int *p;
- scanf("%d",p);
- return 0;
- }
- #include
-
- int main()
- {
- int p;
- scanf("%d",&p);
- switch(p)
- {
- case 1:
- ...;
- case 2:
- ...;
-
- }
-
- return 0;
- }
- #include
-
- int main()
- {
- 'a';//字符
- 'abc';//错误
- "a";//字符串
- "abc";//字符串
-
- return 0;
- }
- #include
-
- int main()
- {
- int a=10;
- a++;
- printf("%d",a++);//a=11而不是12
-
- return 0;
- }
- #include
-
- int main()
- {
- int a=10;
- a++;
- fun(a);
-
- return 0;
- }
-
- void fun(int a)
- {
- printf("%d",a);
- }
- #include
- int fun(int a);
-
- int main()
- {
- int a=10;
- a++;
- fun(a);
-
- return 0;
- }
-
- void fun(float a)
- {
- printf("%d",a);
- }
- #include
- void fun(float a);
-
- int main()
- {
- int a=10;
- a++;
- fun(a);
-
- return 0;
- }
-
- void fun(float a)
- {
- printf("%d",a);
- }
- #include
-
-
- int main()
- {
- int *p,i=500;
- char *s,a=10;
- p=&a;
- s=&i;
- printf("%d %d",*p,*s);
-
- return 0;
- }
结果
- 128010 -12
- --------------------------------
- Process exited after 0.3635 seconds with return value 0
- 请按任意键继续. . .
- #include
-
- void fun(int a,int b,int c)
- {
- printf("%d %d %d",a,b,c);
- }
-
- int main()
- {
- int i=500;
- char a=10;
- fun(i,i++,++i);
-
- return 0;
- }
结果
- 502 501 502
- --------------------------------
- Process exited after 0.4191 seconds with return value 0
- 请按任意键继续. . .
- #include
-
-
- int main()
- {
- int a[20];
- int i;
- int *p=a;
- for(i=0;i<20;i++)
- {
- scanf("%d",a++);
- }
- for(i=0;i<20;i++)
- {
- scanf("%d",p++);
- }
-
- return 0;
- }
- struct node
- {
- char name[20];
- }s;
struct nade 是结构体类姓名
s 是结构体变量
- struct node
- {
- char name[20];
- }s;
- s.name // 结构变量访问成员的方式
- s->name //这样是错误的
- struct node * p;
- p->name // 结构体指针访问结构体成员的方式
- (*p).name // 当然这样也可以 一般人不这样用
- #include
-
-
- int main()
- {
- FILE *fp=NULL;
- if((fp=fopen("D:\zhaozhuang\练习\0816\test.txt","w")==NULL))
- {
- printf("文件不存在。");
- }
- else
- {
- char ch;
- ch=fgetc(fp);
- }
- return 0;
- }
- #include
-
-
- int main()
- {
- FILE *fp=NULL;
- if((fp=fopen("D:\zhaozhuang\练习\08222","R")==NULL))
- {
- printf("文件不存在。");
- }
- return 0;
- }
- #include
- #include
-
- int main()
- {
- FILE *fp=NULL;
- fp=fopen("test.txt","w");
- fwrite("山有木兮木有枝",1,16,fp);
-
-
- return 0;
- }