scanf_s()函数与数组,运行环境VS2013
2021-07-21 15:16 huqi001 阅读(62) 评论(0) 编辑 收藏 举报#include <stdio.h>
#include <windows.h>
#define SIZE 10
#define PAR 72
int main(void)
{
int index, score[SIZE];
int sum=0;
float average;
printf("Enter %d golf scores:\n",SIZE);
for (index = 0; index < SIZE; index++)
scanf_s("%d",&score[index]);
for (index = 0; index < SIZE; index++)
printf("%5d", score[index]);
printf("\n");
for (index = 0; index < SIZE; index++)
sum += score[index];
average = (float)sum / SIZE;
printf("Sum of scores=%d,average=%.2f\n",sum,average);
printf("That's a handicap of %.0f.\n",average-PAR);
system("pause");
return 0;
}