输出文字:
#include<stdio.h>
main()
{
printf("你好,世界!!!\n");
return 0;
}
两个数之和:
#include<stdio.h>
main()
{int a,b,sum;
a=123;
b=456;
printf("%d\n",sum=a+b);
return 0;
}
两个数求最大值:
#include<stdio.h>
int max(int x,int y)
{return (x>y?x:y);}
main()
{int a,b;
scanf("%d,%d",&a,&b);
printf("%d",max(a,b));
return 0;
}
求1*2*3*4*5:
#include<stdio.h>
main()
{int i,t;
t=1;
i=2;
while(i<=2)
{t=t*i;
i=i+1;}
printf("%d",t);
return 0;
}
求1-1/2+1/3-1/4+1/5-1/6....+1/99-1/100的和
#include<stdio.h>
main()
{int sign=1;
double deno=2.0,sum=1.0,term;
while(deno<=100)
{sign=-sign;
term=sign/deno;
sum=sum+term;
deno=deno+1;}
printf("%f\n",sum);
return 0;}