您的位置:首页 > 编程语言 > C语言/C++

C语言第一章作业

2013-10-24 15:51 190 查看
1.输出 This is a c test.

#include"stdio.h"
main()
{
printf("This is a c test. \n");
}

"****************************
2.输出 Very GOOD!
"****************************

#include"stdio.h"
main()
{
printf("****************************\n");
printf(" Very GOOD! \n");
printf("****************************\n");
}

3.调用函数判断最大数并输出
#include"stdio.h"
int max(int x,int y)
{
int z;
if (x>y) z=x;
else z=y;
return (z);
}

main()
{
int a,b,c;
scanf("%d %d",&a,&b);
c=max(a,b);
printf("max=%d",c);
}

4.输入3个数,输出最大数

#include"stdio.h"
main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);

if(a>b)
{
if(a>c)
printf("%d",a);
else if(c>b)
printf("%d",c);
}
else if(a<b)
{
if(b<c)
printf("%d",c);
else if(c>b)
printf("%d",b);
}
else
printf("程序出现未知错误");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: