第1个回答 2013-05-06
#include <stdio.h>
void main()
{
int i,j,n,temp;
for(;;)
{
int a[100] = {0};
puts("请输入一个整数n(不要超过100)");
scanf("%d",&n);
puts("请输入n个数据");
for(i=0; i<n; i++)
{
scanf("%d",&a[i]);
}
for(i = 0;i<n; i++)
{
if(a[i]%2!=0)
{
a[i]=0;
}
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i] < a[j])
{
temp = a[j];
a[j] = a[i];
a[i] = temp;
}
}
}
for(i = 0;i<n;i++)
{
if(a[i]!=0)
{
printf("%d ",a[i]);
}
}
printf("\n");
}
}
//以上代码希望可以帮到你
第2个回答 2013-05-06
#include "stdio.h"
int main()
{
int cnt;
int i,j,max,n;
int s[100];
int buf[100];
printf("please enter number\n");
scanf("%d",&cnt);
printf("please enter %d the byte\n",cnt);
for(i=0;i<cnt;i++)
{
scanf("%d",&s[i]);
}
n = 0 ;
for(i=0;i<cnt;i++)
{
//printf("%d ",s[i]%2);
if(0==(s[i]%2))
{
buf[n] = s[i];
printf("%d ",buf[n]);
n++;
}
}
printf("\n");
for(i=0;i<n;i++)
{
max = buf[i];
for(j=i+1;j<n;j++)
{
if(max<buf[j])
{
max = buf[j];
buf[j] = buf[i];
buf[i] = max;
}
}
printf("%d ",buf[i]);
}
if(n==0) printf("null number \n");
return 0;
}本回答被提问者和网友采纳