小女不胜感激~~~

#include <stdio.h>
#include <conio.h>
int main(void)
{
int a,b,c,d;
int temp,temp1;
clrscr();
scanf("%d %d %d %d",&a,&b,&c,&d);
if(a>b)
temp=b;
else
temp=a;
if(c>d)
temp1=d;
else
temp1=c;
if(temp<temp1)
printf("%d %d ",temp,temp1);
else
printf("%d %d ",temp1,temp);
if(a!=temp)
temp=a;
else
temp=b;
if(c!=temp1)
temp1=c;
else
temp1=d;
if(temp<temp1)
printf("%d %d ",temp,temp1);
else
printf("%d %d ",temp1,temp);
getch();
}
冒泡法
#include<stdio.h>
main()
{
int a[4];
int i,j,temp;
printf("input 4 number:\n");
for(i=0;i<4;i++)
scanf("%d",&a[i]);
for(i=0;i<4;i++)
for(j=4;j>i;j--)
{
if(a[j]>a[j+1])
{
temp=a[j+1];
a[j+1]=a[j];
a[j]=temp;
}
}
for(i=0;i<4;i++)
printf("%d<",a[i]);
getch();
}
[此贴子已经被作者于2007-3-17 11:34:08编辑过]