This commit is contained in:
2025-07-17 11:31:11 +09:00
parent 1cc0c43954
commit e304f900ee
29 changed files with 281 additions and 107 deletions

10
programs/p418/info.json Normal file
View File

@@ -0,0 +1,10 @@
{
"language": "C",
"name": "演習 4-18",
"description": "入力した整数値の個数分アスタリスクを各行に5個ずつ表示するプログラム。",
"output": {
"type": "screenshot",
"content": "./assets/p418.png"
},
"note": ""
}

BIN
programs/p418/main Executable file

Binary file not shown.

25
programs/p418/main.c Normal file
View File

@@ -0,0 +1,25 @@
#include <stdio.h>
#define CHARSPERLINE 5
int main(void) {
int n;
numInput:
printf("Input integer: ");
scanf("%d", &n);
if (n < 1) {
puts("Please input non-zero positive integer.");
goto numInput;
}
for (int i = 1; i <= n; i++) {
putchar('*');
if (i % CHARSPERLINE == 0) {
putchar('\n');
}
}
return 0;
}