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

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

方法一: //用数学函数 #include #include void main() { int a; scanf("%d",&a); printf("%d\n",abs(a)); } 方法二: //判断 #include void main() { int a; scanf("%d",&a); if(a>=0) printf("%d\n",a); else printf("%d\n",-a); }

#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; }

#include #include #include int main(){ int num, i; char * str = NULL; scanf("%d", &num); do str = calloc(7, sizeof(char)); while (str == NULL); sprintf(str, "%d", num); for (i = strlen(str) - 1; i >= 0; i --) { putchar(*(str + ...

#includeint main(){ int zs; double ss; scanf("%d;%lf",&zs,&ss); double sh=ss/zs; printf("%.8f",sh); 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; ...

#include "stdio.h"int main(int argv,char *argc[]){char n,c,i,t,N=40;printf("Input n(int 0

#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 n; int i,c=0; scanf("%d",&n); for(i=1; i

# include"stdio.h" void main() { int i=10,k=0 ,sum=0,a; scanf("%d",&a); //输入一个数 if(a=10); //当条件成立循环上面的语句 sum+=a;} //条件不成立执行这条语句 printf("%d",sum); } 希望对你有一定帮助!!

#include main() { int i,j,m,k,count=0; printf("input m:"); scanf("%d",&m); printf("\ninput k:"); scanf("%d",&k); for(i=m+1;count

网站地图

All rights reserved Powered by www.1862.net

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