#include <stdio.h>
#include <math.h>
#define M_PI 3.141592653589
int main(void) {
double E = 5.0; // 電圧 (V)
double R = 30.0; // 抵抗 (Ω)
double C = 0.7e-6; // キャパシタンス (F)
double t, I;
printf("t (s)\t\tI (A)\n"); // ヘッダー
for (t = 0.0; t <= 0.002; t += 0.0001) { // 0秒から0.002秒まで、0.00002秒刻み
I
= (E
/ R
) * (1 - exp(-t
/ (R
* C
))); // RLC回路の電流計算 printf("%.5f\t%.5f\n", t
, I
); // 結果を表示 }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CgojZGVmaW5lIE1fUEkgMy4xNDE1OTI2NTM1ODkKCmludCBtYWluKHZvaWQpIHsKICAgIGRvdWJsZSBFID0gNS4wOyAgLy8g6Zu75ZynIChWKQogICAgZG91YmxlIFIgPSAzMC4wOyAvLyDmirXmipcgKM6pKQogICAgZG91YmxlIEMgPSAwLjdlLTY7IC8vIOOCreODo+ODkeOCt+OCv+ODs+OCuSAoRikKICAgIGRvdWJsZSB0LCBJOwoKICAgIHByaW50ZigidCAocylcdFx0SSAoQSlcbiIpOyAvLyDjg5jjg4Pjg4Djg7wKCiAgICBmb3IgKHQgPSAwLjA7IHQgPD0gMC4wMDI7IHQgKz0gMC4wMDAxKSB7IC8vIDDnp5LjgYvjgokwLjAwMuenkuOBvuOBp+OAgTAuMDAwMDLnp5LliLvjgb8KICAgICAgICBJID0gKEUgLyBSKSAqICgxIC0gZXhwKC10IC8gKFIgKiBDKSkpOyAvLyBSTEPlm57ot6/jga7pm7vmtYHoqIjnrpcKICAgICAgICBwcmludGYoIiUuNWZcdCUuNWZcbiIsIHQsIEkpOyAvLyDntZDmnpzjgpLooajnpLoKICAgIH0KCiAgICByZXR1cm4gMDsKfQ==