上一页 1 ··· 5 6 7 8 9
摘要: #include <stdio.h>int main(){ /*从键盘读取7个数(1-50)的整数值,每读取一个值打印出该值个数的*号*/ int a,i,n=1; while(n<=7) { do { scanf("%d",&a); }while(a<1||a>50);//每次只读取一个值 for(i=1;i<=a;i++) { printf("*");//打印*号 } n++;//计数 printf("\n"); } getch(); return 0;} 阅读全文
posted @ 2013-03-03 15:00 王井玉 阅读(1622) 评论(0) 推荐(0) 编辑
摘要: #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 王井玉 阅读(728) 评论(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 王井玉 阅读(378) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){/*求0-7所能组成的奇数的个数*/long sum=4, s=4;int j;for (j=2; j<=8; ++j){printf("\n%ld", sum);if (j<=2)//最高位不能为0s*=7;//s=s*7;elses*=8;//s=s*8;sum+=s;}printf("\nsum=%ld",sum);return 0;} 阅读全文
posted @ 2013-03-01 22:58 王井玉 阅读(326) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){/*八进制转换成十进制*/char *p, s[6];//字符串的类型为charint n;p=s;gets(p);n=0;while(*p!='\0'){n=n*8+*p-'0';//printf("n=%d *p-'0'=%d\n", n, *p-'0');*p++;}printf("%d\n",n);return 0;} 阅读全文
posted @ 2013-03-01 20:49 王井玉 阅读(737) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>int output(int number1, int number2, int number3){ printf("809*%ld = 800*%ld + 9*%ld + 1\n",number1, number2, number3); //printf("809*%ld=%ld\n",number1, 809*number1); return 0;}int main(){ /*809*??=800*??+9*??+1,??为两位数,8*??为两位数,9*??为三位数,求??的值及809*??的值*/ i 阅读全文
posted @ 2013-03-01 19:30 王井玉 阅读(1091) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9