level 1
main() { int a=100,b=200; int *p1,*p2; p1=&a; p2=&b; printf("%d,%d\n",a,b); printf("%d,%d",*p1,*p2); getch(); } 2 main() { int *p,a=10,b=1; p=&a; a=*p+b; printf("%d",a); getch(); } 3 main() { int a,b,k=4,m=6,*p1=&k,*p2=&m; a=p1==&m; b=(*p1)/(*p2)+7; printf("%d,%d",a,b); getch(); } 4 main() { float a,b,*p1,*p2,x1,x2,x3,x4; scanf("%f%f",&a,&b); p1=&a; p2=&b; x1=(*p1)+(*p2); x2=(*p1)-(*p2); x3=(*p1)*(*p2); x4=(*p1)/(*p2); printf("%f\n",x1); printf("%f\n",x2); printf("%f\n",x3); printf("%f\n",x4); getch(); } 5 #include
main() { int a,b,*p; scanf("%d%d",&a,&b); p=a; a=b; b=p; printf("%d\n%d\n",a,b); getch(); }
2006年12月22日 15点12分
2
level 1
struct student {int num; char name[10]; float score; }stu1={1,"liming ",470.5},*p; main() {p=&stu1; printf("%d\n",stu1.num); printf("%s\n",(*p).name); printf("%f\n",p->score); getch(); } (2)................................................... struct student {int num; char name[10]; float score; }stu[5]={{1,"liming",470.5},{2,"zhang",480},{3,"shi",410},{4,"hou",490},{5,"song",485}}; main() {int i; float sum=0,aver=0; for(i=0;i<5;i++) sum=sum+stu[i].score; aver=sum/5; printf("平均分是:%f\n",aver); getch(); } (3)....................................................... #define N 10 main() {int i,j; float sum=0,aver=0; struct student {int num; char name[10]; float score; }stu[N]; printf("请输入10个同学学号,姓名,分数:"); for(i=0;i
2006年12月22日 15点12分
3
level 1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2006年12月22日 15点12分
4
level 0
main() {void swap(char*,char*); char str1[20],str2[20],str3[20]; printf("请输入3个字符串,回车分开\n"); gets(str1);gets(str2);gets(str3); if(strcmp(str1,str2)>0) swap(str1,str2); if(strcmp(str1,str3)>0) swap(str1,str3); if(strcmp(str2,str3)>0) swap(str2,str3); printf("排序后为\n"); printf("%s\n%s\n%s\n",str1,str2,str3); getch(); } void swap(char *p1,char *p2) {char t[20]; strcpy(t,p1); strcpy(p1,p2); strcpy(p2,t);
2006年12月22日 15点12分
5