各位大神這些是什么意思?
#include <stdio.h>
#define N 10
//打印分?jǐn)?shù)?
void printScore(int score[])
{
int i;
printf("\n");
for(i=0;i<N;i++)
{
printf("%d ",score[i]); ? ? ? ? ? ? ??
}
printf("\n"); ? ??
}
//計(jì)算考試總分?
int getTotalScore(int score[])
{
int sum = 0;
int i;
for(i=0;i<N;i++)
{
sum+=score[i]; ? ? ? ? ? ? ? ?
}?
return sum;
}
//計(jì)算平均分?
int getAvgScore(int score[])
{
return getTotalScore(score)/N; ??
}
//計(jì)算最高分?
int getMax(int score[])
{
int max = -1;
int i;
for(i=0;i<N;i++)
{
if(score[i]>max)
{
max = score[i]; ? ? ? ? ? ? ?
} ? ? ? ? ? ? ? ?
}?
return max;
}
//計(jì)算最低分?
int getMin(int score[])
{
int min =100;
int i;
for(i=0;i<N;i++)
{
if(score[i]< min)
{
min = score[i]; ? ? ? ? ? ? ?
} ? ? ? ? ? ? ? ?
}?
return min;
}
//分?jǐn)?shù)降序排序?
void sort(int score[])
{
int i,j;
for(i=N-2;i>=0;i--)
{
for(j=0;j<=i;j++)
{
if(score[j]<score[j+1])
{
int temp;
temp = score[j];
score[j] = score[j+1];?
score[j+1]=temp; ? ? ? ? ? ? ? ? ?
} ? ? ? ? ? ? ? ??
} ? ? ? ? ? ? ? ? ??
}
printScore(score); ? ??
}
?
int main()
{
int score[N]={67,98,75,63,82,79,81,91,66,84};
int sum,avg,max,min;
sum = getTotalScore(score);
avg = getAvgScore(score);
max = getMax(score);
min = getMin(score);
printf("總分是:%d\n",sum);
printf("平均分是:%d\n",avg);
printf("最高分是:%d\n",max);
printf("最低分是:%d\n",min);
printf("----------成績排名---------\n");
sort(score);
return 0; ? ?
}
畫圈的那個是什么?畫 { 的那部分有事做什么用的?麻煩各位大神解答一下謝謝?。?!
2017-02-11
這是一個宏定義,是預(yù)編譯命令中的一種,意思是用“N”這個字符常量來表示“10”這個字符,以后凡是出現(xiàn)N的地方系統(tǒng)自動用10替換,記住這里的“10”僅代表一個字符,假如需要用于數(shù)學(xué)計(jì)算,系統(tǒng)會自動進(jìn)行類型轉(zhuǎn)換。。。