-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
119 lines (112 loc) · 4.74 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* main.c*/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h> //äëÿ getch
#include<string.h> // äëÿ strcpy è äðóãèõ
#include "CsFunc.h"
#include "CsPlotFunc.h"
int main(int argc, char *argv[])
{
/* Ñìåíà êîäèðîâêè è î÷èñòêà ýêðàíà */
system("chcp 1251");
system("cls");
/* Âûâîä çàñòàâêè */
char filename[128]="Splash.txt";
char strcatn[2048]={0};
TxtFromFile(filename, strcatn); //Ââîä çàñòàâêè â strcatn
printf("%s\n", strcatn); //âûâîä çàñòàâêè íà ýêðàí
/* Çàãðóçêà ìåíþ */
strcpy(filename, "menu.txt");
char menustr[2048]={0};
TxtFromFile(filename, menustr);
/* Âåëè÷èíû äëÿ âõîäíûõ äàííûõ ðàñ÷åòà*/
int N;
double U, tstart, t1, t2, tend;
double a, b, Uin1, Uin2;
double C, Eps;
int Nmax;
/* Âåëè÷èíû äëÿ âûõîäíûõ äàííûõ ðàñ÷åòà*/
double *ArrT=NULL; //NULL íåîáõîäèì, ÷òîáû ìîæíî áûëî èñïîëüçîâàòü free() äëÿ óêàçàòåëåé, êîòîðûì íå âûäåëåíà ïàìÿòü
double *ArrUin;
ArrUin=NULL;
double *ArrUout=NULL;
double dt;
double W;
double MeaErW;
/* Ïðî÷èå ïåðåìåííûå*/
// int i=0;
int FormArrFlag=0; // ôëàã î ñóùåñòâîâàíèè ìàññèâîâ.
int choice=0;
char smallbuff[128];
/* Îñíîâíîé öèêë */
while(1)
{
printf("%s\n", menustr); //âûâîä ìåíþ
printf("Âûáåðåòå ïóíêò:\n");
fgets(smallbuff, 10, stdin);
// printf("%s", smallbuff);
choice=atoi(smallbuff); //âîçâðàùàåòñÿ 0 â ñëó÷àå íåóäà÷è
switch(choice)
{
/* Ââîä */
case 1: // printf("main:Âû âûáðàëè 1!\n");
InputDataFromCons(&N, &U, &tstart, &t1, &t2, &tend, &a, &b, &Uin1, &Uin2, &C, &Eps, &Nmax); break;
case 2: //printf("main:Âû âûáðàëè 2!\n");
InputDataFromFile(&N, &U, &tstart, &t1, &t2, &tend, &a, &b, &Uin1, &Uin2, &C, &Eps, &Nmax, "InputData.txt"); break;
case 3: printf("main:Âû âûáðàëè 3!\n");
InputDataFromFileForPlots(&N, &tend, &ArrT, &ArrUin, &ArrUout, "OutputResult.txt", &FormArrFlag);
break;
/* Ðàñ÷åò */
case 4:// printf("main:Âû âûáðàëè 4!\n");
printf("Ôîðìèðóåòñÿ ArrT...\n");
FormArrT(N, tstart, tend, &ArrT, &dt);
printf("Ôîðìèðóåòñÿ ArrUin...\n");
FormArrUin(N, U, tstart, t1, t2, tend, ArrT, &ArrUin);
printf("Ôîðìèðóåòñÿ ArrUout...\n");
FormArrUout(N, a, b, Uin1, Uin2, ArrUin, &ArrUout, &FormArrFlag);
// for(int i=0;i<(N+1);i++) printf("main:ArrT[%d]=%lf\n", i, ArrT[i]); //ïðîâåðêà
// for(int i=0;i<(N+1);i++) printf("main:ArrUin[%d]=%lf\n", i, ArrUin[i]); //ïðîâåðêà
// for(int i=0;i<(N+1);i++) printf("main:ArrUout[%d]=%lf\n", i, ArrUout[i]); //ïðîâåðêà
break;
case 5: //printf("main:Âû âûáðàëè 5!\n");
CalcW(&N, U, tstart, t1, t2, tend, a, b, Uin1, Uin2, C, Eps, Nmax, &ArrT, &ArrUin, &ArrUout, &dt, &FormArrFlag, &W, &MeaErW, 0);
break;
/* Âûâîä */
case 6: //printf("main:Âû âûáðàëè 6!\n");
if(FormArrFlag==1) OutputResultToCons(N, ArrT, ArrUin, ArrUout, dt);
else printf("Íåò äàííûõ äëÿ âûâîäà!\n");
break;
case 7: //printf("main:Âû âûáðàëè 7!\n");
if(FormArrFlag==1) OutputResultToFile(N, ArrT, ArrUin, ArrUout, dt, "OutputResult.txt");
else printf("Íåò äàííûõ äëÿ âûâîäà!\n");
break;
case 8: //printf("main:Âû âûáðàëè 8!\n");
OutputWToFile(N, W, MeaErW, "OutputResult.txt");
break;
/* Ãðàôèêè */
case 9: printf("main:Âû âûáðàëè 9!\n");
MainPlotFunc(ArrT, ArrUin, N, tend);
break;
case 10: printf("main:Âû âûáðàëè 10!\n");
MainPlotFunc(ArrT, ArrUout, N, tend);
break;
/* Âûõîä */
case 11: printf("main:Âû âûáðàëè 11!\n");
free(ArrT);
free(ArrUin);
free(ArrUout);
return 0;
break;
/* Îòëàäêà */
case 12:// printf("main:Âû âûáðàëè 12!\n");
CalcW(&N, U, tstart, t1, t2, tend, a, b, Uin1, Uin2, C, Eps, Nmax, &ArrT, &ArrUin, &ArrUout, &dt, &FormArrFlag, &W, &MeaErW, 1);
break;
case 13: //printf("main:Âû âûáðàëè 13!\n");
DebOutputCurrentToCons(N, U, tstart, t1, t2, tend, a, b, Uin1, Uin2, C, Eps, Nmax); break;
default: printf("main:Íåò òàêîãî ïóíêòà!\n"); break;
}
printf("Íàæìèòå ëþáóþ êëàâèøó äëÿ âîçâðàòà â ìåíþ\n");
getch();
}
return 0;
}