draft
This commit is contained in:
10
programs/p410/info.json
Normal file
10
programs/p410/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"language": "C",
|
||||
"name": "演習 4-10",
|
||||
"description": "入力した整数値の個数分縦にアスタリスクを表示するプログラム。",
|
||||
"output": {
|
||||
"type": "screenshot",
|
||||
"content": "./assets/p410.png"
|
||||
},
|
||||
"note": ""
|
||||
}
|
||||
BIN
programs/p410/main
Executable file
BIN
programs/p410/main
Executable file
Binary file not shown.
21
programs/p410/main.c
Normal file
21
programs/p410/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 < 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (n-- > 0) {
|
||||
putchar('*');
|
||||
if (n != 0) {
|
||||
putchar('\n');
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
10
programs/p411/info.json
Normal file
10
programs/p411/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"language": "C",
|
||||
"name": "演習 4-11",
|
||||
"description": "教科書のList 4-10の出力に入力値も表示するように変更したプログラム。",
|
||||
"output": {
|
||||
"type": "screenshot",
|
||||
"content": "./assets/p411.png"
|
||||
},
|
||||
"note": ""
|
||||
}
|
||||
BIN
programs/p411/main
Executable file
BIN
programs/p411/main
Executable file
Binary file not shown.
23
programs/p411/main.c
Normal file
23
programs/p411/main.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int n;
|
||||
|
||||
do {
|
||||
printf("Input positive integer: ");
|
||||
scanf("%d", &n);
|
||||
if (n <= 0) {
|
||||
puts("\aPlease input non-negative, non-zero integer.");
|
||||
}
|
||||
} while (n <= 0);
|
||||
|
||||
printf("Reverse of %d is ", n);
|
||||
while (n > 0) {
|
||||
printf("%d", n % 10);
|
||||
n /= 10;
|
||||
}
|
||||
|
||||
puts(".");
|
||||
|
||||
return 0;
|
||||
}
|
||||
10
programs/p412/info.json
Normal file
10
programs/p412/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"language": "C",
|
||||
"name": "演習 4-12",
|
||||
"description": "入力した正の整数値の桁数を表示するプログラム。",
|
||||
"output": {
|
||||
"type": "screenshot",
|
||||
"content": "./assets/p412.png"
|
||||
},
|
||||
"note": ""
|
||||
}
|
||||
BIN
programs/p412/main
Executable file
BIN
programs/p412/main
Executable file
Binary file not shown.
24
programs/p412/main.c
Normal file
24
programs/p412/main.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int n;
|
||||
|
||||
do {
|
||||
printf("Input positive integer: ");
|
||||
scanf("%d", &n);
|
||||
if (n <= 0) {
|
||||
puts("\aPlease input non-negative, non-zero integer.");
|
||||
}
|
||||
} while (n <= 0);
|
||||
|
||||
int d = 0;
|
||||
int x = n;
|
||||
while (x > 0) {
|
||||
x /= 10;
|
||||
d++;
|
||||
}
|
||||
|
||||
printf("%d is %d digit number.\n", n, d);
|
||||
|
||||
return 0;
|
||||
}
|
||||
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;
|
||||
}
|
||||
10
programs/p46/info.json
Normal file
10
programs/p46/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"language": "C",
|
||||
"name": "演習 4-6",
|
||||
"description": "入力した整数値以下の偶数を出力するプログラム。",
|
||||
"output": {
|
||||
"type": "screenshot",
|
||||
"content": "./assets/p46.png"
|
||||
},
|
||||
"note": ""
|
||||
}
|
||||
BIN
programs/p46/main
Executable file
BIN
programs/p46/main
Executable file
Binary file not shown.
22
programs/p46/main.c
Normal file
22
programs/p46/main.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int n;
|
||||
|
||||
printf("Input positive integer: ");
|
||||
scanf("%d", &n);
|
||||
|
||||
if (n <= 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int i = 1;
|
||||
|
||||
while (2*i <= n) {
|
||||
printf("%d ", 2*i++);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
10
programs/p47/info.json
Normal file
10
programs/p47/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"language": "C",
|
||||
"name": "演習 4-7",
|
||||
"description": "入力した整数値以下の2のべき乗を出力するプログラム。",
|
||||
"output": {
|
||||
"type": "screenshot",
|
||||
"content": "./assets/p47.png"
|
||||
},
|
||||
"note": ""
|
||||
}
|
||||
BIN
programs/p47/main
Executable file
BIN
programs/p47/main
Executable file
Binary file not shown.
23
programs/p47/main.c
Normal file
23
programs/p47/main.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int n;
|
||||
|
||||
printf("Input positive integer: ");
|
||||
scanf("%d", &n);
|
||||
|
||||
if (n <= 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int i = 2;
|
||||
|
||||
while (i <= n) {
|
||||
printf("%d ", i);
|
||||
i <<= 1;
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
10
programs/p48/info.json
Normal file
10
programs/p48/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"language": "C",
|
||||
"name": "演習 4-8",
|
||||
"description": "教科書のList 4-8を1未満の時に改行を出力しないよにしたプログラム。",
|
||||
"output": {
|
||||
"type": "screenshot",
|
||||
"content": "./assets/p48.png"
|
||||
},
|
||||
"note": ""
|
||||
}
|
||||
BIN
programs/p48/main
Executable file
BIN
programs/p48/main
Executable file
Binary file not shown.
20
programs/p48/main.c
Normal file
20
programs/p48/main.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int n;
|
||||
|
||||
printf("Input positive integer: ");
|
||||
scanf("%d", &n);
|
||||
|
||||
if (n < 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (n-- > 0) {
|
||||
putchar('*');
|
||||
}
|
||||
|
||||
putchar('\n');
|
||||
|
||||
return 0;
|
||||
}
|
||||
10
programs/p49/info.json
Normal file
10
programs/p49/info.json
Normal 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
BIN
programs/p49/main
Executable file
Binary file not shown.
27
programs/p49/main.c
Normal file
27
programs/p49/main.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user