mirror of
https://github.com/Kaehvaman/OAIP.git
synced 2025-01-31 01:08:25 +04:00
lab17 add №7
This commit is contained in:
parent
78eda1475f
commit
f89b7120bd
@ -76,6 +76,24 @@ void F2(int n, FILE* f) {
|
||||
}
|
||||
}
|
||||
|
||||
void G3(int n, FILE* f);
|
||||
|
||||
void F3(int n, FILE* f) {
|
||||
if (n > 0) {
|
||||
G3(n - 1, f);
|
||||
fprintf(f, "G3(%d) returned\n", n - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void G3(int n, FILE* f) {
|
||||
printf_s("*");
|
||||
fprintf(f, "G3(%d) -> print(*) \n", n);
|
||||
if (n > 1) {
|
||||
F3(n - 3, f);
|
||||
fprintf(f, "F3(%d) returned\n", n - 3);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
FILE* fout = fopen("trace.txt", "w");
|
||||
if (fout == NULL) {
|
||||
@ -86,21 +104,37 @@ int main() {
|
||||
//printf("%lld", fact(5)); // 1
|
||||
|
||||
f1(11, fout);
|
||||
fprintf(fout, "f1(%d) returned\n", 11);
|
||||
|
||||
fprintf(fout, "\n");
|
||||
printf_s("\n\n");
|
||||
f2(11, fout);
|
||||
fprintf(fout, "f2(%d) returned\n", 11);
|
||||
|
||||
fprintf(fout, "\n");
|
||||
printf_s("\n\n");
|
||||
f3(11, fout);
|
||||
fprintf(fout, "f3(%d) returned\n", 11);
|
||||
|
||||
fprintf(fout, "\n");
|
||||
printf_s("\n\n");
|
||||
recEGE1(3, fout);
|
||||
fprintf(fout, "recEGE1(%d) returned\n", 3);
|
||||
|
||||
fprintf(fout, "\n");
|
||||
printf_s("\n\n");
|
||||
F1(10, fout);
|
||||
fprintf(fout, "F1(%d) returned\n", 10);
|
||||
|
||||
fprintf(fout, "\n");
|
||||
printf_s("\n\n");
|
||||
F2(1, fout);
|
||||
fprintf(fout, "F2(%d) returned\n", 1);
|
||||
|
||||
fprintf(fout, "\n");
|
||||
printf_s("\n\n");
|
||||
F3(11, fout);
|
||||
fprintf(fout, "F3(%d) returned\n", 11);
|
||||
|
||||
fclose(fout);
|
||||
return 0;
|
||||
|
@ -9,6 +9,7 @@ f1(3) returned
|
||||
f1(5) returned
|
||||
f1(7) returned
|
||||
f1(9) returned
|
||||
f1(11) returned
|
||||
|
||||
f2(1) -> print(1)
|
||||
f2(1) returned
|
||||
@ -21,6 +22,7 @@ f2(7) returned
|
||||
f2(9) -> print(9)
|
||||
f2(9) returned
|
||||
f2(11) -> print(11)
|
||||
f2(11) returned
|
||||
|
||||
f3(11) -> print(11)
|
||||
f3(9) -> print(9)
|
||||
@ -37,6 +39,7 @@ f3(7) returned
|
||||
f3(9) -> print(9)
|
||||
f3(9) returned
|
||||
f3(11) -> print(11)
|
||||
f3(11) returned
|
||||
|
||||
recEGE1(3) && (n >= 1) == true -> print( 3)
|
||||
recEGE1(2) && (n >= 1) == true -> print( 2)
|
||||
@ -59,6 +62,7 @@ recEGE1(1) && (n >= 1) == true -> print( 1)
|
||||
2)recEGE1(0) returned
|
||||
2)recEGE1(1) returned
|
||||
2)recEGE1(2) returned
|
||||
recEGE1(3) returned
|
||||
|
||||
F1(10) -> print(10)
|
||||
F1(7) -> print(7)
|
||||
@ -78,6 +82,7 @@ F1(3) -> print(3)
|
||||
1)F1(3) returned
|
||||
2)F1(2) returned
|
||||
2)F1(6) returned
|
||||
F1(10) returned
|
||||
|
||||
F2(1) -> print(1)
|
||||
F2(2) -> print(2)
|
||||
@ -94,3 +99,15 @@ F2(4) -> print(4)
|
||||
1)F2(5) returned
|
||||
2)F2(7) returned
|
||||
2)F2(4) returned
|
||||
F2(1) returned
|
||||
|
||||
G3(10) -> print(*)
|
||||
G3(6) -> print(*)
|
||||
G3(2) -> print(*)
|
||||
F3(-1) returned
|
||||
G3(2) returned
|
||||
F3(3) returned
|
||||
G3(6) returned
|
||||
F3(7) returned
|
||||
G3(10) returned
|
||||
F3(11) returned
|
||||
|
Loading…
Reference in New Issue
Block a user