From a4638192c6658c80d1deea581c32bc3991e4610d Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Fri, 22 Mar 2024 12:43:24 +0100 Subject: [PATCH] diophantine solution printing improvements --- zad1/src/main.c | 5 +++-- zad2/src/main.adb | 5 +++-- zad3/src/main.rs | 5 +++-- zad4/src/main.c | 5 +++-- zad5/src/main.adb | 5 +++-- zad6/src/main.rs | 5 +++-- zad7/c/main.c | 5 +++-- 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/zad1/src/main.c b/zad1/src/main.c index 8ba8e8a..550d299 100644 --- a/zad1/src/main.c +++ b/zad1/src/main.c @@ -11,10 +11,11 @@ int main(int argc, char *argv[]) { printf("gcd(a, b): %lu\n", gcd(atol(argv[1]), atol(argv[2]))); printf("factorial(a): %lu\n", factorial(atol(argv[1]))); Result *r = diophantine(atol(argv[1]), atol(argv[2]), atol(argv[3])); + printf("diophantine(a, b, c): "); if (r == NULL) - printf("dupa\n"); + printf("there's no solution\n"); else - printf("diophantine(a, b, c): %ld, %ld\n", r->n, r->m); + printf("%ld, %ld\n", r->n, r->m); return 0; } diff --git a/zad2/src/main.adb b/zad2/src/main.adb index d9ea9b3..85586ef 100644 --- a/zad2/src/main.adb +++ b/zad2/src/main.adb @@ -16,9 +16,10 @@ begin Put_Line("gcd(a, b):" & Natural'Image(gcdResult)); Put_Line("factorial(a):" & Natural'Image(factorialResult)); + Put("diophantine(a, b, c): "); if not diophantineResult.resultExists then - Put_Line("dupa"); + Put_Line("there's no solution"); else - Put_Line("diophantine(a, b, c): " & Integer'Image(diophantineResult.n) & "," & Integer'Image(diophantineResult.m)); + Put_Line(Integer'Image(diophantineResult.n) & "," & Integer'Image(diophantineResult.m)); end if; end Main; diff --git a/zad3/src/main.rs b/zad3/src/main.rs index 522c727..2d9db80 100644 --- a/zad3/src/main.rs +++ b/zad3/src/main.rs @@ -29,9 +29,10 @@ fn main() { println!("gcd(a, b): {}", module.gcd(10, 5)); println!("factorial(a): {}", module.factorial(5)); let r = module.diophantine(1027, 712, 1); + print!("diophantine(a, b, c): "); if r.is_none() { - println!("dupa"); + println!("there's no solution"); } else { - println!("diophantine(a, b, c): {}, {}", r.unwrap().0, r.unwrap().1); + println!("{}, {}", r.unwrap().0, r.unwrap().1); } } diff --git a/zad4/src/main.c b/zad4/src/main.c index a63b857..3fd7469 100644 --- a/zad4/src/main.c +++ b/zad4/src/main.c @@ -12,10 +12,11 @@ int main(int argc, char *argv[]) { printf("gcd(a, b): %u\n", gcd(atol(argv[1]), atol(argv[2]))); printf("factorial(a): %u\n", factorial(atol(argv[1]))); Result r = diophantine(atol(argv[1]), atol(argv[2]), atol(argv[3])); + printf("diophantine(a, b, c): "); if (!r.resultExists) - printf("dupa\n"); + printf("there's no solution\n"); else - printf("diophantine(a, b, c): %d, %d\n", r.n, r.m); + printf("%d, %d\n", r.n, r.m); return 0; } diff --git a/zad5/src/main.adb b/zad5/src/main.adb index f845744..e59ef24 100644 --- a/zad5/src/main.adb +++ b/zad5/src/main.adb @@ -40,9 +40,10 @@ begin Put_Line("gcd(a, b):" & Natural'Image(gcdResult)); Put_Line("factorial(a):" & Natural'Image(factorialResult)); + Put("diophantine(a, b, c): "); if not diophantineResult.resultExists then - Put_Line("dupa"); + Put_Line("there's no solution"); else - Put_Line("diophantine(a, b, c): " & Integer'Image(diophantineResult.n) & "," & Integer'Image(diophantineResult.m)); + Put_Line(Integer'Image(diophantineResult.n) & "," & Integer'Image(diophantineResult.m)); end if; end Main; diff --git a/zad6/src/main.rs b/zad6/src/main.rs index aa892fc..24d3ad7 100644 --- a/zad6/src/main.rs +++ b/zad6/src/main.rs @@ -18,10 +18,11 @@ fn main() { println!("gcd(a, b): {}", gcd(10, 5)); println!("factorial(a): {}", factorial(5)); let r = diophantine(1027, 712, 1); + print!("diophantine(a, b, c): "); if r.resultExists == 0 { - println!("dupa"); + println!("there's no solution"); } else { - println!("diophantine(a, b, c): {}, {}", r.n, r.m); + println!("{}, {}", r.n, r.m); } } } diff --git a/zad7/c/main.c b/zad7/c/main.c index a63b857..3fd7469 100644 --- a/zad7/c/main.c +++ b/zad7/c/main.c @@ -12,10 +12,11 @@ int main(int argc, char *argv[]) { printf("gcd(a, b): %u\n", gcd(atol(argv[1]), atol(argv[2]))); printf("factorial(a): %u\n", factorial(atol(argv[1]))); Result r = diophantine(atol(argv[1]), atol(argv[2]), atol(argv[3])); + printf("diophantine(a, b, c): "); if (!r.resultExists) - printf("dupa\n"); + printf("there's no solution\n"); else - printf("diophantine(a, b, c): %d, %d\n", r.n, r.m); + printf("%d, %d\n", r.n, r.m); return 0; }