www.1862.net > 入门C语言题:从键盘上输入任意一个整数,然后输出...

入门C语言题:从键盘上输入任意一个整数,然后输出...

方法一: //用数学函数#include#includevoid main(){int a;scanf("%d",&a);printf("%d\n",abs(a));} 方法二://判断#includevoid main(){int a;scanf("%d",&a);if(a>=0)printf("%d\n",a);elseprintf("%d\n",-a);} Problem Description 求实数的...

#include "stdio.h" int main() { int n,sum=0,i; printf("请输入一个整数:"); scanf("%d",&n); for(i=1;i

给你写了个,运行通过,你看看吧,记得采纳哦O(∩_∩)O~ #include int main(){ int num,i=0; printf("please input a numble:"); while(1){ scanf("%d",&num); if(num0){ num/=10; i++; } break; } printf("It's width is %d",i); }

楼上程序错了,得不了正确的结果!少了一行代码! 应; #include void main() { int a,b,c,min; printf("请任意输入三个整数:") scanf("%d%d%d",&a,&b,&c); if(a>=b)min=b; else min=a; if(min>c)min=c; printf("%d\n",min); }

#include int main() { int n; scanf("%d", &n); printf("%d %u %f %c", n,n,(float)n,(char)n); }

#include void main( ) { int a,b,c,d,e; printf("请输入一个四位数的整数:"); scanf("%d",&a); b=a/1000; c=(a-b*1000)/100; d=(a-b*1000-c*100)/10; e=a%10; printf("%d %d %d %d",e,d,c,b); return 0; }

代码1. // 输入3个数,要求按从小到大顺序输出 #include int main() { int a,b,c,t; printf("请输入三个数:"); scanf("%d%d%d",&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; ...

#includevoid main(){int n,m,i;printf("输入n的值:"); scanf("%d",&n);if(n==0||n==1){m=1;printf("n的阶乘为:%d\n",m);}else{m=1;for(i=n;i>0;i--)m=m*i;printf("n的阶乘为:%d\n",m);}}//刚写的,运行通过

#include main(){float a,b,c,temp;//输入a b c以空格隔开scanf("%f%f%f",&a,&b,&c);if (a>b){//如果a大于b则将a和b进行互换temp=a;a=b;b=temp;}if (a>c){//如果a大于c则将a和c进行互换temp=a;a=c;c=temp;}if (b>c){//如果b大于c则将b和c进行互...

#include int main() { int a,b,c,temp; scanf("%d %d %d",&a,&b,&c); if(ab { temp=a; a=b; b=temp; } if(b>c) printf("%d %d %d",a,b,c); else if(c

网站地图

All rights reserved Powered by www.1862.net

copyright ©right 2010-2021。
www.1862.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com