标签:number ret sort max one use c++ think clu
#include <stdio.h>
#define a 7
void raw_input(int r[]){
int i;
puts("please enter integer");
for(i=0;i<a;i++){
scanf("%d",&r[i]);
}
}
void raw_output(int r[]){
int i;
puts("the numbers of this ayyay includes ");
for(i=0;i<a;i++){
printf("%d ",r[i]);
}
printf("\n");
}
int summation(int r[]){
int i,s;
s=0;
for(i=0;i<a;i++)
s=r[i]+s;
return(s);
}
void sort_one(int r[]){
int i,j,t,c;
for(j=1;j<a;j++){
for(i=0;i<a-j;i++){
if(r[i]<r[i+1]){
t=r[i+1];
r[i+1]=r[i];
r[i]=t;
}
}
}
for(c=0;c<a;c++)
printf("%d ",r[c]);
}
void sort_tow(int r[]){
int i,j,t,k,c;
for(j=0;j<a-1;j++){
k=j;
for(i=j+1;i<a;i++){
if(r[k]<r[i])
k=i;
if(i!=k){
t=r[i];
r[i]=r[k];
r[k]=t;
}
}
}
for(c=0;c<a;c++)
printf("%d ",r[c]);
}
int find_the_maxium(int r[]){
int i,h,s;
s=0;
for(i=0;i<a-1;i++){
if(r[i]<r[i+1])
s=i+1;
}
h=r[s];
return(h);
}
void find(int r[]){
int e;
scanf("%d",&e);
if(e<a)
printf("%d\n",r[e]);
else
puts("The number entered is outside the established range");
}
void main(){
int array[a],sum,max;
raw_input(array);
raw_output(array);
sum=summation(array);
puts("the sun of the number in the array is equal to");
printf("%d\n",sum);
puts("sort form largest to smallest");
sort_one(array);
printf("\n");
puts("sort form smallest to largest");
sort_tow(array);
printf("\nthe maxium in the array is\n");
max=find_the_maxium(array);
printf("%d\n",max);
puts("think you foy your use");
printf("please inPlease enter a number less than %d\n",a);
find(array);
}
标签:number ret sort max one use c++ think clu
原文地址:http://www.cnblogs.com/lifenglin/p/7953837.html