#include <stdio.h>
#include <math.h>
int main() {
// パラメータの定義
double R = 3000.0; // 抵抗 (オーム)
double L = 0.001; // インダクタンス (ヘンリー)
double V_E = 5.0; // 電源電圧 (ボルト)
int steps = 6; // 計算ステップ数(0を含めて7点)
double t_max = 0.001; // 計算する最大時間 (秒)
int i; // ループ変数
// 時定数 τ = L / R
tau = L / R;
// 時間変化に伴う電流 I(t) を計算
printf("Time(s)\tCurrent(A)\n"); for (i = 0; i <= steps; i++) { // ループの外で宣言した i を使用
time = t_max
* i
/ steps
; I
= (V_E
/ R
) * (1 - exp(-time / tau
)); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CgppbnQgbWFpbigpIHsKICAgIC8vIOODkeODqeODoeODvOOCv+OBruWumue+qQogICAgZG91YmxlIFIgPSAzMDAwLjA7ICAvLyDmirXmipcgKOOCquODvOODoCkKICAgIGRvdWJsZSBMID0gMC4wMDE7ICAgLy8g44Kk44Oz44OA44Kv44K/44Oz44K5ICjjg5jjg7Pjg6rjg7wpCiAgICBkb3VibGUgVl9FID0gNS4wOyAgIC8vIOmbu+a6kOmbu+WcpyAo44Oc44Or44OIKQogICAgZG91YmxlIHRpbWUsIEksIHRhdTsKICAgIGludCBzdGVwcyA9IDY7ICAgICAgLy8g6KiI566X44K544OG44OD44OX5pWw77yIMOOCkuWQq+OCgeOBpjfngrnvvIkKICAgIGRvdWJsZSB0X21heCA9IDAuMDAxOyAvLyDoqIjnrpfjgZnjgovmnIDlpKfmmYLplpMgKOenkikKICAgIGludCBpOyAgLy8g44Or44O844OX5aSJ5pWwCgogICAgLy8g5pmC5a6a5pWwIM+EID0gTCAvIFIKICAgIHRhdSA9IEwgLyBSOwoKICAgIC8vIOaZgumWk+WkieWMluOBq+S8tOOBhumbu+a1gSBJKHQpIOOCkuioiOeulwogICAgcHJpbnRmKCJUaW1lKHMpXHRDdXJyZW50KEEpXG4iKTsKICAgIGZvciAoaSA9IDA7IGkgPD0gc3RlcHM7IGkrKykgeyAgLy8g44Or44O844OX44Gu5aSW44Gn5a6j6KiA44GX44GfIGkg44KS5L2/55SoCiAgICAgICAgdGltZSA9IHRfbWF4ICogaSAvIHN0ZXBzOwogICAgICAgIEkgPSAoVl9FIC8gUikgKiAoMSAtIGV4cCgtdGltZSAvIHRhdSkpOwogICAgICAgIHByaW50ZigiJWZcdCVmXG4iLCB0aW1lLCBJKTsKICAgIH0KCiAgICByZXR1cm4gMDsKfQo=