為什么1,4,5函數輸出的是零啊
#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;
}
2018-11-11
用的快速排序法