mdsk.net
当前位置:首页 >> C语言程序,利用函数调用:随机输入3个整型数,利... >>

C语言程序,利用函数调用:随机输入3个整型数,利...

#incudeint max(int x,int y) { return (x>y)?(x):(y); }void main() { int a,b,c,m; scanf("%d%d%d",&a,&b,&c); m=max(a,max(b,c)); printf("%d\n",m);}

#include void zds(int a,int b,int c); int main(void) { int i,j,k; printf(" 请输入3个整数(数与数之间用空格隔开):"); scanf("%d %d %d",&i,&j,&k); zds(i,j,k); return 0; } void zds(int a,int b,int c) { int temp; if(a{ temp=b; b=a; a=temp; } if(a{ temp=c; c=a; a=temp; } if(b{ temp=c; c=b; b=temp; } printf(" 输入的3个整数中最大值为:%d\n",a); }

#include <stdio.h> void input(int*a) { printf("请输入三个数:"); scanf("%d %d %d",&a[0],&a[1],&a[2]); } void output(int*a) { printf("%d %d %d\n",a[0],a[1],a[2]); } void reverse(int*a) { printf("%d %d %d\n",a[2],a[1],a[0]); } void main(){ int a[3]; input(a); output(a); reverse(a); }

用数组保存3个整型数据,然后用循环一个个比较得到最大数 代码如下:#include "stdio.h" void main() { int a[3],i,max,min; printf("请输入3个数:\n"); for(i=0;iscanf("%d",&a[i]); max=a[0]; for(i=1;iif(a[i]>max) max=a[i]; printf("max=%d\n",max); printf("最大数是%d\n",max+min); } ps:我没运行过,自己试试吧

#include int main() { int a=0,b=0,c=0; float ave =0; scanf("%d%d%d",&a,&b,&c); ave = (float)((a+b+c)/(3*1.0)); printf("Average of %d、%d and %d is %.2f\n",a,b,c,ave); }22 33 44 Average of 22、33 and 44 is 33.00 Press any key to continue

#include int b[4][3];void main(){ void convert(int a[3][4]); int i,j,a[3][4]; for(i=0;i

#include<stdio.h> int main() { int a,b,c; printf("输入三个数"); scanf("d%d%d%",acb,c); int t,k; t=a>b?a:b; k=t>c?t:c; printf("d%",k); return 0; }

#include int main(void) { float num1,num2,num3; printf("请输入三个整数:"); scanf("%f%f%f",&num1,&num2,&num3); printf("三个数中最大的数是:%f\n",num1>(num2>num3?num2:num3)?num1:(num2>num3?num2:num3)); return 0; }

#include "stdio.h" void main() { int a, b, c; int *pa = &a, *pb = &b, *pc = &c; printf("key in \"a\":"); scanf("%d", pa); printf("\n"); printf("key in \"b\":"); scanf("%d", pb); printf("\n"); printf("key in \"c\":"); scanf("%d", pc);

main() {int a,b,c,t; scanf("%d%d%d",&a,&b,&c); if(a {t=a;a=b;b=t;} if(a {t=a;a=c;c=t;} if(b {t=b;b=c;c=t;} printf("%d %d %d\n",a,b,c); getch(); }

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