判断3个数大小,C语言,初初初初初学的自自自学的,别太深奥.

发布时间:2024-05-21 15:01 发布:上海旅游网

问题描述:

逻辑是有,但是语法错了.怎么写????999
求完整的,谢谢.有什么要注意?

问题解答:

#include <stdio.h>

void main()
{
int a,b,c,d;
printf("Please input three numbers:\n");
scanf("%d%d%d",&a,&b,&c);
if(a>=b)
d=a;
else
d=b;

if(c>=d)
d=c;
printf("the max number is: %d\n",d);
}

#include <stdio.h>
void main()
{
int a,b,c,d,x,y,z;
scanf("%d,%d,%d",&a,&b,&c);
if (a>b)
d=a;
else if (b>c)
d=b;
else
d=c;
x=d;
printf("%d \n",x);
if (a==x)
{
a=b;
b=c;
}
else if (b==x)
{
b=c;
}
if (a>b)
{
printf("%d \n",a);
printf("%d \n",b);
}
else
{
printf("%d \n",b);
printf("%d \n",a);
}
}

最原始的:
mian()
{
int a,b,c,t;
printf("Input the data:\n");
scanf("%d,%d,%d",&a,%b,&c);
if(a>b)
{t=a;a=b;b=t}/*实现a和b的互换*/
if(a>c)
{t=a;a=c;c=t}/*实现a和c的互换*/
if(b>c)
{t=b;b=c;c=t}/*实现b和c的互换*/
printf("%5d,%5d,%5d\n",a,b,c);
}
用这个好,起泡法:
#include"stdio.h"
main()
{
char a[100],b[100];
int i,n,m;
printf("Enter the number of the arry a:\n");
scanf("%d",&n);
printf("Enter arry a:\n");
for(i=0;i<n;i++)
scanf("%c",&a[i]);
printf("\n");
printf("Enter the number of the arry b:\n");
scanf("%d",&m);
printf("Enter arry b:\n");
for(i=0;i<m;i++)
scanf("%c",&b[i]);
printf("\n");

fun();
}

int fun(char a[],char b[])
{
int i,j,num,x;
for(i=0;a[i]!='\0';i++);
num=i;
for(j=0;b[j]!='\0';j++)
a[j+num]=b[j];
x=num+j;
for(i=0;i<x;i++)
printf("%C",&a[i]);

}

将3个数由小到大输出行吗?
main()
{
int x,y,z,t;
scanf("%d%d%d",&x,&y,&z);
if (x>y)
{t=x;x=y;y=t;} /*交换x,y的值*/
if(x>z)
{t=z;z=x;x=t;}/*交换x,z的值*/
if(y>z)
{t=y;y=z;z=t;}/*交换z,y的值*/
printf("small to big: %d %d %d\n",x,y,z);
}
我不知道你用C还是C++,所以,前后你要自己补充,C的话,main前加void,C++的话,我很少用,你自己修改行吗?实在不行,我有空再来

#include"stdio.h"
void main()
{
int a,b,c,t;
printf("please input there number:");
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;c=t}
printf("%d,%d,%d\n",a,b,c);
}
注意符号不要丢~~

热点新闻