Archived
41 lines
746 B
C
Executable File
41 lines
746 B
C
Executable File
/*
|
|
25. Выполнить подготовку для рисования графика функции y=sin(x), x [-2pi;2pi].
|
|
С шагом pi/180. Значения (x,y) записать в файл «sinraw.txt», как есть
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <math.h>
|
|
|
|
#define M_PI 3.14159265358979323846
|
|
|
|
|
|
|
|
|
|
void writeXY()
|
|
{
|
|
FILE *file = fopen("sinraw.txt", "w");
|
|
if (file == NULL)
|
|
{
|
|
printf("Error open\n");
|
|
return;
|
|
}
|
|
|
|
double a = 0;
|
|
double b = 2 * M_PI;
|
|
double h = 0.1;
|
|
|
|
for (double x = a; x <= b; x += h)
|
|
{
|
|
double y = sin(x);
|
|
fprintf(file, "%f %f\n", x, y);
|
|
}
|
|
|
|
fclose(file);
|
|
}
|
|
|
|
int main()
|
|
{
|
|
writeXY();
|
|
return 0;
|
|
}
|