- 博客(49)
- 收藏
- 关注
原创 例7.4
例7.4#include<stdio.h>int main(){float add(float x,float y);float a,b,c;printf("Please enter a and b:");scanf("%f,%f",&a,&b);c=add(a,b);printf("sum is %f\n",c);return 0;}float...
2019-02-16 17:59:50
206
原创 例7.3
例7.3#include<stdio.h>int main(){int max(float x,float y);float a,b;int c;scanf("%f,%f",&a,&b);c=max(a,b);printf("max is %d\n",c);return 0;}int max(float x,float y){float z;...
2019-02-16 17:54:21
205
原创 例7.2
例7.2#include<stdio.h>int main(){int max(int x,int y);int a,b,c;printf("please enter two integer number:");scanf("%d,%d",&a,&b);c=max(a,b);printf("max is %d\n",c);return 0;}in...
2019-02-16 17:47:27
192
原创 例7.1
例7.1#include<stdio.h>int main(){void print_star();void print_message();print_star();print_message();print _star();return 0;}void print_star(){printf("*****************\n");}void p...
2019-02-16 17:37:51
157
原创 例6.9
例6.9#include<stdio.h>#include<string.h>int main(){char str[3][20];char string[20];int i;for(i=0;i<3;i++)gets(str[i]);if(strcmp(str[0],str[1])>0)strcpy(string,str[0]);else...
2019-02-16 17:29:47
132
原创 例6.8
例6.8#include<stdio.h>int main(){char string[81];int i,num=0;,word=0;char c;gets(string);for(i=0;(c=string[i])!='\0';i++)if(c==' ') word=0;else if(word==0){word=1;num++;}printf("Th...
2019-02-16 17:18:01
170
原创 例6.7
例6.7#include<stdio.h>int main(){char diamond[][5]={{' ',' ','*'},{' ','*',' ','*'},{'*',' ',' ',' ','*'}{' ','*',' ','*'}{' ',' ','*'}};int i,j;for(i=0;i<5;i++){for(j=0;j<5;j++)pr...
2019-02-16 17:06:43
180
1
原创 例6.6
例6.6#include<stdio.h>int main(){char c[15]={'I',' ','a','m',' ','a',' ','s','t','u','d','e','n','t','.'};int i;for(i=0;i<15;i++)printf("%c",c[i]);printf("\n");return 0;}
2019-02-16 16:58:44
199
原创 例6.5
例6.5#include<stdio.h>int main(){int i,j,row=0,colum=0,max;int a[3][4]={{1,2,3,4},{9,8,7,6},{-10,10,-5,2}};max=a[0][0];for(i=0;i<=2;i++)for(j=0j<=3;j++)if(a[i][j]>max){max=a[i...
2019-02-16 16:52:52
242
原创 例6.4
例6.4#include<stdio.h>int main(){int a[2][3]={{1,2,3},{4,5,6}};int b[3][2],i,j;printf("array a:\n");for(i=0;i<=1;i++){for(j=0;j<=2;j++){printf("%5d",a[i][j]);b[j][i]=a[i][j];}...
2019-02-16 16:45:41
172
原创 例6.3
例6.3#include<stdio.h>int main(){int a[10];int i,j,k;printf("input 10 numbers:\n");for(i=0;i<10;i++)scanf("%d",&a[i]);printf("\n");for(j=0;j<9;j++)for(i=0;i<9-j;i++)if(a[..
2019-02-16 16:06:06
240
原创 例6.2
例6.2#include<stdio.h>int main(){int i;int f[20]={1,1};for(i<2;i<20;i++)f[i]=f[i-2]+f[i-1];for(i=0;i<20;i++){if(i%5==0)printf("\n");printf("%12d",f[i]);}printf("\n");retur...
2019-02-16 15:56:09
174
原创 例6.1
例6.1#include<stdio.h>int main(){int i,a[10];for(i=0;i<=9;i++)a[i]=i;for(i=9;i>=0;i--)printf("%d",a[i]);printf("\n");return 0;}
2019-02-16 15:44:48
192
原创 例5.11
例5.11#include<stdio.h>int main(){char c;c=getchar();while(c!='\n'){if((c>='a'&&c<='z')||(c>='A'&&c<='Z')){if(c>='W'&&c<='Z'||c>='w&
2019-02-16 15:40:45
145
原创 例5.10
例5.10#include<stdio.h>#include<math.h>int main(){int n,k,i,m=0;for(n=101;n<=200;n=n+2){k=sqrt(n);for(i=2;i<=k;i++)if(n%i==0)break;if(i>=k+1){printf("%d",n);m=m+1;}...
2019-02-16 15:33:10
217
1
原创 例5.9
例5.9#include<stdio.h>int main(){int n,i;printf("please enter a integer number,n=?");scanf("%d",&n);for(i=2;i<n;i++)if(n%i==0)break;if (i<n)printf("%d is not a prime number.\n"...
2019-02-16 15:24:35
132
1
原创 例5.8
例5.8#include<stdio.h>int main(){int f1=1,f2=1,f3;int i;printf("%112d\n%12d\n",f1,f2);for(i=1;i<=38;i++){f3=f1+f2;printf("%12d\n",f3);f1=f2;f2=f3;}return 0;}
2019-02-16 15:16:51
182
原创 例5.7
例5.7#include<stdio.h>#include<math.h>int main(){int sign=1;double pi=0.0,n=1.0,term=1.0;while(fabs(term)>=1e-6){pi =pi+term;n=n+2;sign=-sign;term=sign/n;}pi=pi*4;printf("...
2019-02-16 15:07:57
173
原创 例5.6
例5.6#include<stdio.h>int main(){int i,j,n=0;for(i=1;i<=4i++)for(j=1;j<=5;j++,n++){if(n%5==0)printf("\n");printf("%d\t",i*j);}printf("\n");return 0;}
2019-02-16 15:02:49
117
原创 例5.5
例5.5#includ<stdio.h>int main(){int n;for(n=100;n<=200;n++){if(n%3==0)continue;printf("%d",n);}printf("\n");return 0;}
2019-02-16 14:58:20
133
原创 例5.4
例5.4#include<stdio.h>#define SUM 100000int main(){float amount,aver,total;int i;for (i=1;total=0;i<=1000;i++){printf("please enter amount:");scabf("%f",&amount);total = total+a...
2019-02-16 14:53:18
125
原创 例5.3
例5.3(1)#include<stdio.h>int main(){int i,sum=0;printf("please enter i,i=?");scanf("%d",&i);while(i<=10){sum=sum+i;i++;} printf("sum=%d\n",sum); return 0;}(2)#include&l...
2019-02-16 14:26:35
90
原创 例5.2
例5.2#include<stdio.h>int main(){int i=1,sum=0;do {sum=sum+i;i++;}while(i<=100);printf("sum=%d\n",sum);return 0;}
2019-02-16 14:13:15
171
原创 例5.1
例5.1#include<stdio.h>int main(){int i=1,sum=0;while(i<=100){sum=sum+i;i++;}printf("sum=%d\n",sum);}
2019-02-16 14:07:12
156
原创 例4.10
例4.10#include<stdio.h>int main(){int c,s;float p,w,d,f;printf("please enter price,weight,discount:");scanf("%f%f%d",&p&w&s);if (s>=3000) c=12;switch(c){case 0: d=0;brea...
2019-02-16 14:03:50
151
原创 例4.9
例4.9#include<stdio.h>#include<math.h>int main(){double a,b,c,disc,x1,x2,realpart,imagpart;scanf("%lf,%lf,%lf",&a,&b,&c);printf("The equation");if (fabs(a)<=1e-6)pri...
2019-02-16 13:53:11
152
原创 例4.8
例4.8#include<stdio.h>int main(){int year,leap;printf("enter year:");scanf("%d",&year);if (year%4==0){if (year%100==0){if (year%400==0)leap=1;elseleap=0;}elseleap=1;}else ...
2019-02-16 13:35:54
157
原创 例4.7
例4.7#include<stdio,h>int main(){void action1(int,int),action2(int,int);char ch;int a=15,b=23;ch=getchar();switch(ch){case'a':case'A':action1(a,b);break;case'b':case'B':action2(a,b);...
2019-02-16 13:12:23
110
原创 例4.6
例4.6#include<stdio.h>int main(){char grade;scanf("%c",&grade);printf("Your score:");switch(grade){case 'A':printf("85~100\n");break;case 'B':printf("70~84\n");break;case 'C':print...
2019-02-13 15:38:06
172
原创 例4.5
例4.5#include<stdio.h>int main{int x,y;scanf("%d",&x);if(x<0);y=-1;elseif(x==0) y=0;else y=1;printf("x=%d,y=%d\n",x,y);return 0;}
2019-02-13 15:26:33
119
原创 例4.4
例4.4#include<stdio.h>int main(){char ch;scanf("%c",&ch);ch=(ch>='A'&&ch<='Z')?(ch+32):ch;printf("%c\n",ch);return 0;}
2019-02-13 15:20:47
246
1
原创 例4.3
例4.3#include<stdio.h>int main(){float a,b,c,t;scanf("%f,%f,%f",&a,&b,&c);if(a>b){t=a;a=b;b=t;}if(a>c){t=a;a=c;c=t;}if(b>c){t=b;b=c;c=t;}printf("%5.2f...
2019-02-13 15:11:51
141
原创 例4.2
例4.2#include<stdio.h>int main(){float a,b,t;scanf("%f,%f",&a,&b);if(a>b){t=a;a=b;b=t;}printf("%5.2f,%5.2f\n",a,b);return 0;}
2019-02-13 14:55:53
139
原创 例4.1
例4.1#include<stdio.h>#include<math.h>int main(){double a,b,c,disc,x1,x2,p,q;scanf("%lf%lf%lf",&a,&b,&c);disc=b*b-4*a*c;if(disc<0)printf("This equation hasn't real r...
2019-02-13 14:42:35
121
原创 例3.10
例3.10#include<stdio,h>int main(){char c1,c2;c1=getchar();c2=c1+32;putchar(c2);putchar('\n');return 0;}
2019-02-13 14:29:58
116
原创 例3.9
例3.9#include<stdio.h>int main(){char a,b,c;a=getchar( );b=getchar( );c=getchar( );putchar(a);putchar(b);putchar(c);putchar('\n');return 0;}
2019-02-13 14:25:19
75
原创 例3.8
例3.8#include<stdio.h>int main(){char a='B',b='O',c='Y';putchar(a);putchar(b);putchar(c);putchar('\n');return 0;}
2019-02-13 14:20:20
94
原创 例3.7
例3.7#include<stdio.h>int main(){float a;a=10000/3.0;printf("%f\n",a);return 0;}
2019-02-13 14:08:44
116
原创 例3.6
例3.6#include<stdio.h>int main(){double a=1.0;printf("%f\n",a/3);return 0;}
2019-02-13 14:03:36
125
原创 例3.5
例3.5#include<stdio.h>#include<math.h>int main(){double a,b,c,disc,x1,x2,p,q;scanf("%lf%lf%lf",&a,&b,&c);disc=b*b-4*a*c;p=-b/(2.0*a);q=sqrt(disc)/(2.0*a);x1=p+q;x2=p-...
2019-02-13 13:57:01
140
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人