下载此文档

用C、C 、C#、JAVA做的一个相同的小程序(输出三个数种的最大值).doc


文档分类:IT计算机 | 页数:约3页 举报非法文档有奖
1/3
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/3 下载此文档
文档列表 文档介绍
1 C比较三个数的大小:
#include ""
int max(int x,int y,int z)
{
int A;
if(x>y>z) or (x>z>y); A=x;
if(y>x>z) or (y>z>x); A=y;
if(z>x>y) or (z>y>x); A=z;
return (A);
}
void main()
{
int a,b,c,d;
printf("请输入三个整数");
scanf("%d%d%d",&a,&b&c);
d=max(a,b,c);
printf("max=%d\n",d);
}
2 C++比较三个数的大小
#include <>
int max(int x,int y)
{
if (x>=y)
return x;
else
return y;
}
void main()
{
int a,b,c,d,e;
cin>>a>>b>>d;
c=max(a,b);
e=max(c,d);
cout<<”The max number is”<<e<<endl;
return 0;
}
3 C#比较三个数的大小
static void Main(string[] args)
{
int a = 0, b = 0, c = 0, max = 0;
try
{
("请输入第一个数字:");
a = (());
("请输入第二个数字:");
b = (());
("请输入第三个数字");
c = (());
}
catch(Exception e)
{
("输入的不是数字!");
return;
}
if (a > b)
max = a;
else
max = b;
if (max < c)
{
max = c;
}
("最大数字是:" + ());
}
4 JAVA比较三个数大小
public class test {
public static void main(String[] args) {
int a = 0;
int b = 0;
int c = 0;
int s = 0;
tr

用C、C 、C#、JAVA做的一个相同的小程序(输出三个数种的最大值) 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数3
  • 收藏数0 收藏
  • 顶次数0
  • 上传人水中望月
  • 文件大小33 KB
  • 时间2018-11-13