Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "functions.h"
- const int T = 2;
- int N = 0;
- const double U1 = 12., U2 = 20., V1 = 32., V2 = 60.;
- int main(int argc, char** argv){
- print_zast();
- int input=0, exit=0;
- while(exit != 1){
- printf("1. Контрольный расчет для N точек\n");
- printf("2. Расчет параметра с заданной точностью\n");
- printf("3. Чтение данных из файлов\n");
- printf("4. Выход\n");
- printf("Selection: ");
- scanf("%d",&input);
- switch (input)
- {
- case 1: {
- printf("Input number of points:\n");
- scanf("%d", &N);
- double array_time[N], array_u_in[N], array_u_out[N];
- int i = 0;
- form_time(N, array_time, T);
- form_u_in(N, array_u_in, array_time);
- form_u_out(N, array_u_out, array_u_in, U1, U2, V1, V2);
- form_tbl(N, array_time, array_u_in, array_u_out);
- FILE *f1, *f2, *f3;
- f1=fopen("massiv_time.txt","w");
- f2=fopen("massiv_U_in.txt", "w");
- f3=fopen("massiv_U_out.txt", "w");
- for (i=0;i<N;i++){
- fprintf(f1,"%6.3f\n", array_time[i]);
- fprintf(f2,"%6.3f\n", array_u_in[i]);
- fprintf(f3,"%6.3f\n", array_u_out[i]);
- }
- fclose(f1);
- fclose(f2);
- fclose(f3);
- break;
- }
- case 2: {
- printf("Calculating U in minimum\n");
- parametr_u_in_min(T);
- printf("Calculating U out minimum\n");
- parametr_u_out_min(U1, U2, V1, V2, T);
- break;
- }
- case 3: {
- FILE *f1, *f2, *f3;
- int i=0;
- f1=fopen("massiv_time.txt","r");
- if(f1 == NULL){
- printf("There is no massiv_time.txt file");
- break;
- }
- f2=fopen("massiv_U_in.txt", "r");
- if(f2 == NULL){
- printf("There is no massiv_U_in.txt file");
- break;
- }
- f3=fopen("massiv_U_out.txt", "r");
- if(f3 == NULL){
- printf("There is no massiv_U_out.txt file");
- break;
- }
- char tmp_time[80], tmp_u_in[80], tmp_u_out[80];
- printf("№\ttime\tU in\tU out\n");
- while(!feof(f1) && !feof(f2) && !feof(f3)){
- fgets(tmp_time, 80, f1);
- fgets(tmp_u_in, 80, f2);
- fgets(tmp_u_out, 80, f3);
- printf("%3d\t%s\t%s\t%s\n", i, strtok(tmp_time, "\n"),strtok(tmp_u_in, "\n"), strtok(tmp_u_out, "\n"));
- i++;
- }
- fclose(f1);
- fclose(f2);
- fclose(f3);
- break;
- }
- case 4: {
- exit = 1;
- break;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement