帮我用c语言完成以下x(t)=-2tsin(t2),0≤t≤8,从0开始,以△t=0.01、0.02、0.04、0.08、0.1、0.25、0.5、1等为间隔
时间: 2023-12-28 07:08:23 浏览: 79
好的,以下是符合你要求的 C 语言代码:
#include <stdio.h>
#include <math.h>
int main() {
double t, x, delta_t;
int i;
for (i = 1; i <= 8 / 0.01; i++) {
t = i * 0.01;
x = -2 * t * sin(t * t);
printf("%.2f %.4f\n", t, x);
}
for (i = 1; i <= 8 / 0.02; i++) {
t = i * 0.02;
x = -2 * t * sin(t * t);
printf("%.2f %.4f\n", t, x);
}
for (i = 1; i <= 8 / 0.04; i++) {
t = i * 0.04;
x = -2 * t * sin(t * t);
printf("%.2f %.4f\n", t, x);
}
for (i = 1; i <= 8 / 0.08; i++) {
t = i * 0.08;
x = -2 * t * sin(t * t);
printf("%.2f %.4f\n", t, x);
}
for (i = 1; i <= 8 / 0.1; i++) {
t = i * 0.1;
x = -2 * t * sin(t * t);
printf("%.2f %.4f\n", t, x);
}
for (i = 1; i <= 8 / 0.25; i++) {
t = i * 0.25;
x = -2 * t * sin(t * t);
printf("%.2f %.4f\n", t, x);
}
for (i = 1; i <= 8 / 0.5; i++) {
t = i * 0.5;
x = -2 * t * sin(t * t);
printf("%.2f %.4f\n", t, x);
}
for (i = 1; i <= 8 / 1; i++) {
t = i * 1;
x = -2 * t * sin(t * t);
printf("%.2f %.4f\n", t, x);
}
return 0;
}
阅读全文