ttuu
2018-11-11 22:32
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
int totalpoint(int score[])
{
static int totalpoint;
int i;
for(i=0;i>9;i++)
{
totalpoint=score[i]+totalpoint;
}
printf("总分为%d分\n",totalpoint);
return totalpoint;
}
int toppoint(int score[])
{
int toppoint=score[0];
int n;
for(n=0;n<9;n++)
{
if(score[n]>toppoint)
{
toppoint=score[n];
}
}
printf("最高分为%d分\n",toppoint);
return toppoint;
}
int thelowestpoint(int score[])
{
int lowpoint=score[0];
int n;
for(n=0;n<9;n++)
{
if(score[n]<lowpoint)
{
lowpoint=score[n];
}
}
printf("最低分为%d分\n",lowpoint);
return lowpoint;
}
int averagepoint(int score[])
{
int i=totalpoint(score);
int averagepoint=i/10;
printf("平均分为%d分\n",averagepoint);
return averagepoint;
}
int sort(int score[],int left,int right)
{
int i,j,temp,k,e;
i=left;
j=right;
temp=score[left];
while(i!=j)
{
while(score[i]>temp&&i<j)
j--;
while(score[j]<temp&&i>j)
i++;
if(i<j)
{
k=score[i];
score[i]=score[j];
score[j]=k;
}
}
score[i]=temp;
score[left]=score[i];
sort(score,left,i-1);
sort(score,i+1,right);
for(e=0;e<9;e++)
{
printf("数组排序后:%d",score);
}
}
int main()
{
int score[10]={67,98,75,63,82,79,81,91,66,84};
totalpoint(score);
toppoint(score);
thelowestpoint(score);
averagepoint(score);
sort(score,0,9);
return 0;
}
用的快速排序法
C语言入门
926027 学习 · 20793 问题
相似问题