#include <stdio.h>
#include <math.h>
#define R 3000
#define L 0.001
#define E 5
#define MAX_TIME 0.1
#define NUM_POINTS 10
int main() {
double current = 0.0;
double tau = L / R;
double dt = MAX_TIME / NUM_POINTS;
double voltage = E;
int i;
printf("Time (s), Current (A)\n");
for (i = 0; i <= NUM_POINTS; i++) {
current
= (voltage
/ R
) * (1 - exp(-time / tau
));
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CgojZGVmaW5lIFIgMzAwMCAgICAgICAKI2RlZmluZSBMIDAuMDAxICAgICAKI2RlZmluZSBFIDUgICAgICAgICAKI2RlZmluZSBNQVhfVElNRSAwLjEgICAKI2RlZmluZSBOVU1fUE9JTlRTIDEwICAKCmludCBtYWluKCkgewogICAgZG91YmxlIGN1cnJlbnQgPSAwLjA7ICAgIAogICAgZG91YmxlIHRpbWUgPSAwLjA7ICAgICAgCiAgICBkb3VibGUgdGF1ID0gTCAvIFI7ICAgICAKICAgIGRvdWJsZSBkdCA9IE1BWF9USU1FIC8gTlVNX1BPSU5UUzsgIAogICAgZG91YmxlIHZvbHRhZ2UgPSBFOyAgICAgIAogICAgaW50IGk7ICAgICAgICAgICAgICAgICAgIAogICAgcHJpbnRmKCJUaW1lIChzKSwgQ3VycmVudCAoQSlcbiIpOwoKICAgIGZvciAoaSA9IDA7IGkgPD0gTlVNX1BPSU5UUzsgaSsrKSB7CiAgICAgICAgY3VycmVudCA9ICh2b2x0YWdlIC8gUikgKiAoMSAtIGV4cCgtdGltZSAvIHRhdSkpOwogICAgCiAgICAgICAgcHJpbnRmKCIlbGYsICVsZlxuIiwgdGltZSwgY3VycmVudCk7CiAgICAKICAgICAgICB0aW1lICs9IGR0OwogICAgfQoKICAgIHByaW50Zigi6KiI566X44GM57WC5LqG44GX44G+44GX44Gf44CCXG4iKTsKCiAgICByZXR1cm4gMDsKfQo=
Time (s), Current (A)
0.000000, 0.000000
0.010000, 0.001667
0.020000, 0.001667
0.030000, 0.001667
0.040000, 0.001667
0.050000, 0.001667
0.060000, 0.001667
0.070000, 0.001667
0.080000, 0.001667
0.090000, 0.001667
0.100000, 0.001667
計算が終了しました。