tnfh.net
当前位置:首页 >> C语言简单代码 >>

C语言简单代码

发个超级无敌简单的: #include void main() { printf("Hello world!\n"); }

#include int fun(int num1, int num2);void main(){int num1, num2;int sum;printf("请输入两个整数:\n");scanf("%d %d", &num1, &num2);if(num1 > num2){int tmp = num1;num1 = num2;num2 = tmp;}sum = fun(num1, num2);printf("大于等于%d小...

#include main() { int a,b,c; printf("请输入两个整数:"); scanf("%d%d",&a,&b); c=a+b; printf("这两个数的和是:\n%d+%d=%d",a,b,c); }

#include int denominator(int a,int b) { if(a%b!=0) denominator(b,a%b); else return b; } main() { int a,b; printf("Please input a,b--"); scanf("%d,%d",&a,&b); printf("Common denominator of a,b is %d\n",denominator(a,b)); getch(); }

b用int类型更好 否则可能有浮点陷阱 #includemain(){ float e=0; int b=1,n; printf("e=1+1/2+1/3……,请输入n的值:\n"); scanf("%d",&n); for(b=1;b

#include void main() { float a,b; char d; printf("请输入两个数a,b:"); scanf("%f,%f"&a,&b); printf("请输入符号d"); scanf("%c",d); switch(d) { case'+':printf("%f\n,a+b);break; case'-':printf("%f\n,a-b);break; case'*':printf("%...

for(count1=0,count2=1;count1

你好,很高兴为你解答,这道题就是用一个for循环和利用余数来做,代码如下: #include int main() { int i; for(i = 1; ; ++i) { if(i % 5 == 1 && i % 6 == 5 && i % 7 == 4 && i % 11 == 10) break; } printf("%d\n", i); return 0; }

#includevoid main() { float x,y,z; char c; scanf("%f%c%f",&x,&c,&y); switch ( c ) { case '+': z=x+y; break; case '-': z=x-y; break; case '*': z=x*y; break; case '/': z=( y==0 )?(0):(x/y); break; default: z=0; break; } printf("%...

网站首页 | 网站地图
All rights reserved Powered by www.tnfh.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com