draft
This commit is contained in:
10
programs/p45/info.json
Normal file
10
programs/p45/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"language": "C",
|
||||
"name": "演習 4-5",
|
||||
"description": "教科書のList 4-7のスタートを0から1へ書き換えたプログラム。",
|
||||
"output": {
|
||||
"type": "screenshot",
|
||||
"content": "./assets/p45.png"
|
||||
},
|
||||
"note": ""
|
||||
}
|
||||
BIN
programs/p45/main
Executable file
BIN
programs/p45/main
Executable file
Binary file not shown.
21
programs/p45/main.c
Normal file
21
programs/p45/main.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int n;
|
||||
|
||||
printf("Input positive integer: ");
|
||||
scanf("%d", &n);
|
||||
|
||||
if (n <= 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int i = 1;
|
||||
|
||||
while (i <= n) {
|
||||
printf("%d ", i++);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user