draft
This commit is contained in:
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;
|
||||
}
|
||||
Reference in New Issue
Block a user