摘要: #include "stdio.h"struct student{ int x; char c;}a;void f1(struct student b);void f2(struct student *b);void main(void){ a.x=3; a.c='a'; f1(a); printf("%d,%c\n", a.x, a.c); f2(&a); printf("%d,%c\n", a.x, a.c);}void f1(struct student b){ b.x=20; b.c='y 阅读全文
posted @ 2013-03-02 17:27 王井玉 阅读(731) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>int main(){ //两个字符串的连接程序 char a[100]="abcd"; char b[100]="efgh"; int i=0,j=0; while(a[i]!='\0') i++; while(b[j]!='\0') { a[i++]=b[j++]; } puts(a); // getch(); return 0;} 阅读全文
posted @ 2013-03-02 16:33 王井玉 阅读(224) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>int main(){ //判断一个素数能被几个9整除 long int sum=9,num9=9;//数据类型为长整型 int zi,n=1,c9=1; scanf("%d",&zi); while(n!=0) { if(!(sum%zi)) n=0; else { num9=num9*10;//sum9=sum9*10; sum=sum+num9; c9++; } } printf("%ld can be divided by %d\"9\"",sum,c9);//\&quo 阅读全文
posted @ 2013-03-02 16:16 王井玉 阅读(373) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <math.h>int main(){/*一个偶数总能表示为两个素数的和*/int a, b, c, d;scanf("%d",&a);if (2==a||4==a)//1,2,3都是素数printf("%d=%d+%d\n",a, a/2, a/2);for (b=3;b<=a/2;b++)//这也会有发现的{for (c=2;c<sqrt(b);c++)//这个部分很容易出错的if (b%c==0)break;if (c>sqrt(b))d=a-b 阅读全文
posted @ 2013-03-02 14:43 王井玉 阅读(379) 评论(0) 推荐(0) 编辑