// ①1~100の整数のうち「6の倍数」の個数を表示するプログラムを作成しなさい、ただし、for文とif文を用いて作成すること
// #include <stdio.h>
// int main()
// {
// int i, cnt = 0;
// for (i = 1; i <= 100; i++)
// cnt += !(i % 6);
// printf("%d個\n", cnt);
// return 0;
// }
// ②1次元配列を用いて5人分の数学の得点を100点満点で入力し、「数学の得点の最小値と最大値」を画面表示、およびファイルに書き出すプログラムを作成しなさい。ただし、書き出し用ファイル名は「sugaku.txt」にしなさい。
#include <stdio.h>
int main()
{
int i, a[5], min, max;
char s[]="min=%d, max=%d\n";
FILE
*fp
= fopen("sugaku.txt", "w"); for (i = 0; i < 5; ++i) {
if (i == 0) {
min = max = a[i];
} else {
if (min > a[i])min = a[i];
if (max < a[i])max = a[i];
}
}
return 0;
}
Ly8g4pGgMe+9njEwMOOBruaVtOaVsOOBruOBhuOBoeOAjDbjga7lgI3mlbDjgI3jga7lgIvmlbDjgpLooajnpLrjgZnjgovjg5fjg63jgrDjg6njg6DjgpLkvZzmiJDjgZfjgarjgZXjgYTjgIHjgZ/jgaDjgZfjgIFmb3LmlofjgahpZuaWh+OCkueUqOOBhOOBpuS9nOaIkOOBmeOCi+OBk+OBqAovLyAjaW5jbHVkZSA8c3RkaW8uaD4KLy8gaW50IG1haW4oKQovLyB7Ci8vICAgaW50IGksIGNudCA9IDA7Ci8vICAgZm9yIChpID0gMTsgaSA8PSAxMDA7IGkrKykKLy8gICAgIGNudCArPSAhKGkgJSA2KTsKLy8gICBwcmludGYoIiVk5YCLXG4iLCBjbnQpOwovLyAgIHJldHVybiAwOwovLyB9CgovLyDikaEx5qyh5YWD6YWN5YiX44KS55So44GE44GmNeS6uuWIhuOBruaVsOWtpuOBruW+l+eCueOCkjEwMOeCuea6gOeCueOBp+WFpeWKm+OBl+OAgeOAjOaVsOWtpuOBruW+l+eCueOBruacgOWwj+WApOOBqOacgOWkp+WApOOAjeOCkueUu+mdouihqOekuuOAgeOBiuOCiOOBs+ODleOCoeOCpOODq+OBq+abuOO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