Negative days completion.
This commit is contained in:
10
programs/abs/info.json
Normal file
10
programs/abs/info.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"language": "C",
|
||||
"name": "演習課題 2",
|
||||
"description": "整数値を読み込み、その絶対値を出力するプログラム。",
|
||||
"output": {
|
||||
"type": "screenshot",
|
||||
"content": "./assets/abs.png"
|
||||
},
|
||||
"note": ""
|
||||
}
|
||||
BIN
programs/abs/main
Executable file
BIN
programs/abs/main
Executable file
Binary file not shown.
17
programs/abs/main.c
Normal file
17
programs/abs/main.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int x, y;
|
||||
|
||||
printf("Input integer: ");
|
||||
scanf("%d", &x);
|
||||
|
||||
y = x;
|
||||
|
||||
if (y < 0)
|
||||
y = -y;
|
||||
|
||||
printf("Absolute value of %d is %d.\n", x, y);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user