自己学习编程时间比较短,现在把一下自己以前刚刚接触C++时的程序上传一下,有空可以看看

键盘输入十个数,找出最大值和最小值。

#include<iostream.h>
void main ()
{
int a[10];
int i,t,max,min;
cout<<"input 10 numbers:"<<endl;
for(i=0;i<10;i++)
cin>>a[i];
for(i=0;i<10;i++)
{
min=a[0];
if(a[0]>a[i])
{ min=a[i];
a[0]=min;
}
}
for(i=0;i<10;i++)
{max=a[9];
if(a[9]<a[i])
{max=a[i];
a[9]=max;
}
}
cout<<"排序后最大值为:"<<a[9]<<endl;
cout<<"最小值为:"<<a[0]<<endl;
cout<<endl;
}

运行结果:

posted @ 2014-03-05 19:52  打完BOSS去上课  阅读(315)  评论(2编辑  收藏  举报