#1
by asahi » 5年前
下記コードは私がコーディングしたものになります。変数名のつけ方やコーディング方法で至らぬ点がありましたら指摘いただきたいです。よろしくお願いします。
本コードの意味
学生の数と合格点数を入力し、合格点を満たしている学籍番号を出力するプログラム
※学生のテストの点数は授業の欠席回数によって減点されるようになっている
コード:
#include <stdio.h>
#define PENALTYSCORE 5
#define STUDENT_NUM_MAX 100
int main(void){
int student_num = 0; /*学生数*/
int pass_point = 0; /*合格点*/
int student_id = 1; /*学籍番号*/
int absence_time[STUDENT_NUM_MAX] = {0}; /*欠席回数*/
int test_score[STUDENT_NUM_MAX] = {0}; /*テスト点数*/
int total_score[STUDENT_NUM_MAX] = {0}; /*総合点数*/
/*学生数、合格点取得*/
scanf("%d %d",&student_num,&pass_point);
//printf("学生数は%dです,合格点は%dです\n",student_num,pass_point);
/*合格者判断処理*/
for(student_id = 1; student_id <= student_num; student_id++)
{
scanf("%d %d",&test_score[student_id],&absence_time[student_id]); /*テスト点数と欠席回数の取得*/
total_score[student_id] = test_score[student_id] - (PENALTYSCORE * absence_time[student_id]); /*得点処理*/
/*確認*/
//printf("学籍番号%dの総合点数は%dです\n",student_id,total_score[student_id]);
/*0点処理*/
if(total_score[student_id] < 0)
{
total_score[student_id] = 0;
}
}
/*合格者出力*/
for(student_id = 1; student_id <= student_num; student_id++)
{
if(total_score[student_id] >= pass_point)
{
printf("%d\n",student_id);
}
}
return 0;
}
下記コードは私がコーディングしたものになります。変数名のつけ方やコーディング方法で至らぬ点がありましたら指摘いただきたいです。よろしくお願いします。
本コードの意味
学生の数と合格点数を入力し、合格点を満たしている学籍番号を出力するプログラム
※学生のテストの点数は授業の欠席回数によって減点されるようになっている
[code]
#include <stdio.h>
#define PENALTYSCORE 5
#define STUDENT_NUM_MAX 100
int main(void){
int student_num = 0; /*学生数*/
int pass_point = 0; /*合格点*/
int student_id = 1; /*学籍番号*/
int absence_time[STUDENT_NUM_MAX] = {0}; /*欠席回数*/
int test_score[STUDENT_NUM_MAX] = {0}; /*テスト点数*/
int total_score[STUDENT_NUM_MAX] = {0}; /*総合点数*/
/*学生数、合格点取得*/
scanf("%d %d",&student_num,&pass_point);
//printf("学生数は%dです,合格点は%dです\n",student_num,pass_point);
/*合格者判断処理*/
for(student_id = 1; student_id <= student_num; student_id++)
{
scanf("%d %d",&test_score[student_id],&absence_time[student_id]); /*テスト点数と欠席回数の取得*/
total_score[student_id] = test_score[student_id] - (PENALTYSCORE * absence_time[student_id]); /*得点処理*/
/*確認*/
//printf("学籍番号%dの総合点数は%dです\n",student_id,total_score[student_id]);
/*0点処理*/
if(total_score[student_id] < 0)
{
total_score[student_id] = 0;
}
}
/*合格者出力*/
for(student_id = 1; student_id <= student_num; student_id++)
{
if(total_score[student_id] >= pass_point)
{
printf("%d\n",student_id);
}
}
return 0;
}
[/code]