This commit is contained in:
2025-07-10 12:10:31 +09:00
parent e2d2e70dfb
commit b103fac43e
48 changed files with 488 additions and 106 deletions

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

@@ -0,0 +1,10 @@
{
"language": "C",
"name": "演習 4-9",
"description": "入力した整数値の個数分$+$と$-$を交互に出力するプログラム。",
"output": {
"type": "screenshot",
"content": "./assets/p49.png"
},
"note": ""
}

BIN
programs/p49/main Executable file

Binary file not shown.

27
programs/p49/main.c Normal file
View File

@@ -0,0 +1,27 @@
#include <stdio.h>
int main(void) {
int n;
printf("Input positive integer: ");
scanf("%d", &n);
if (n <= 0) {
return 1;
}
int i = 0;
while (i < n) {
if (i % 2) {
putchar('-');
} else {
putchar('+');
}
i++;
}
putchar('\n');
return 0;
}