started assignment and added programs

This commit is contained in:
2025-05-08 00:28:02 +09:00
parent 3ff7ace93a
commit 8912215a06
14 changed files with 130 additions and 102 deletions

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

@@ -0,0 +1,10 @@
{
"language": "C",
"name": "演習課題2",
"description": "電卓とC言語での演算の違いを比較する。",
"output": {
"type": "screenshot",
"content": "./assets/comp.png"
},
"note": ""
}

16
programs/comp/main.c Normal file
View File

@@ -0,0 +1,16 @@
#include <stdio.h>
// Using function macro cuz im lazy
#define CALC(T,E) printf("Result: %"#T"\n", E);
int main(void) {
CALC(.6f,(5/2+1.5/2))
CALC(.6f,(((int)2.5+4.0)/5))
CALC(d,((int)(1.5+3)/2))
CALC(.6f,(4+2*(double)(6/4)))
CALC(.6f,((int)3.3/1.1+(double)2/4))
return 0;
}

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

@@ -0,0 +1,10 @@
{
"language": "C",
"name": "演習課題1 演習2ー5",
"description": "2つの整数値を読み込み、前者の値が後者の値の何%であるかを倍精度浮動小数点数として表示するプログラム。",
"output": {
"type": "screenshot",
"content": "./assets/p25.png"
},
"note": ""
}

14
programs/p25/main.c Normal file
View File

@@ -0,0 +1,14 @@
#include <stdio.h>
int main(void) {
int a, b;
printf("Integer a: ");
scanf("%d", &a);
printf("Integer b: ");
scanf("%d", &b);
printf("Value of a is %f%% of b.\n", (double)a / (double)b * 100.0);
return 0;
}

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

@@ -0,0 +1,10 @@
{
"language": "C",
"name": "演習課題1 演習2ー6",
"description": "身長を整数値として読み込み、標準体重を実数小数点以下1桁として表示するプログラム。なお標準体重は$0.9(height - 100)$で求めるものとする。",
"output": {
"type": "screenshot",
"content": "./assets/p26.png"
},
"note": ""
}

12
programs/p26/main.c Normal file
View File

@@ -0,0 +1,12 @@
#include <stdio.h>
int main(void) {
int height;
printf("Input your height in cm: ");
scanf("%d", &height);
printf("Standard weight is %.1fkg.\n", 0.9 * (double)(height - 100));
return 0;
}