diophantine solution printing improvements
This commit is contained in:
parent
1081e52ad9
commit
a4638192c6
7 changed files with 21 additions and 14 deletions
|
@ -11,10 +11,11 @@ int main(int argc, char *argv[]) {
|
||||||
printf("gcd(a, b): %lu\n", gcd(atol(argv[1]), atol(argv[2])));
|
printf("gcd(a, b): %lu\n", gcd(atol(argv[1]), atol(argv[2])));
|
||||||
printf("factorial(a): %lu\n", factorial(atol(argv[1])));
|
printf("factorial(a): %lu\n", factorial(atol(argv[1])));
|
||||||
Result *r = diophantine(atol(argv[1]), atol(argv[2]), atol(argv[3]));
|
Result *r = diophantine(atol(argv[1]), atol(argv[2]), atol(argv[3]));
|
||||||
|
printf("diophantine(a, b, c): ");
|
||||||
if (r == NULL)
|
if (r == NULL)
|
||||||
printf("dupa\n");
|
printf("there's no solution\n");
|
||||||
else
|
else
|
||||||
printf("diophantine(a, b, c): %ld, %ld\n", r->n, r->m);
|
printf("%ld, %ld\n", r->n, r->m);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,10 @@ begin
|
||||||
|
|
||||||
Put_Line("gcd(a, b):" & Natural'Image(gcdResult));
|
Put_Line("gcd(a, b):" & Natural'Image(gcdResult));
|
||||||
Put_Line("factorial(a):" & Natural'Image(factorialResult));
|
Put_Line("factorial(a):" & Natural'Image(factorialResult));
|
||||||
|
Put("diophantine(a, b, c): ");
|
||||||
if not diophantineResult.resultExists then
|
if not diophantineResult.resultExists then
|
||||||
Put_Line("dupa");
|
Put_Line("there's no solution");
|
||||||
else
|
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 if;
|
||||||
end Main;
|
end Main;
|
||||||
|
|
|
@ -29,9 +29,10 @@ fn main() {
|
||||||
println!("gcd(a, b): {}", module.gcd(10, 5));
|
println!("gcd(a, b): {}", module.gcd(10, 5));
|
||||||
println!("factorial(a): {}", module.factorial(5));
|
println!("factorial(a): {}", module.factorial(5));
|
||||||
let r = module.diophantine(1027, 712, 1);
|
let r = module.diophantine(1027, 712, 1);
|
||||||
|
print!("diophantine(a, b, c): ");
|
||||||
if r.is_none() {
|
if r.is_none() {
|
||||||
println!("dupa");
|
println!("there's no solution");
|
||||||
} else {
|
} else {
|
||||||
println!("diophantine(a, b, c): {}, {}", r.unwrap().0, r.unwrap().1);
|
println!("{}, {}", r.unwrap().0, r.unwrap().1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,11 @@ int main(int argc, char *argv[]) {
|
||||||
printf("gcd(a, b): %u\n", gcd(atol(argv[1]), atol(argv[2])));
|
printf("gcd(a, b): %u\n", gcd(atol(argv[1]), atol(argv[2])));
|
||||||
printf("factorial(a): %u\n", factorial(atol(argv[1])));
|
printf("factorial(a): %u\n", factorial(atol(argv[1])));
|
||||||
Result r = diophantine(atol(argv[1]), atol(argv[2]), atol(argv[3]));
|
Result r = diophantine(atol(argv[1]), atol(argv[2]), atol(argv[3]));
|
||||||
|
printf("diophantine(a, b, c): ");
|
||||||
if (!r.resultExists)
|
if (!r.resultExists)
|
||||||
printf("dupa\n");
|
printf("there's no solution\n");
|
||||||
else
|
else
|
||||||
printf("diophantine(a, b, c): %d, %d\n", r.n, r.m);
|
printf("%d, %d\n", r.n, r.m);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,10 @@ begin
|
||||||
|
|
||||||
Put_Line("gcd(a, b):" & Natural'Image(gcdResult));
|
Put_Line("gcd(a, b):" & Natural'Image(gcdResult));
|
||||||
Put_Line("factorial(a):" & Natural'Image(factorialResult));
|
Put_Line("factorial(a):" & Natural'Image(factorialResult));
|
||||||
|
Put("diophantine(a, b, c): ");
|
||||||
if not diophantineResult.resultExists then
|
if not diophantineResult.resultExists then
|
||||||
Put_Line("dupa");
|
Put_Line("there's no solution");
|
||||||
else
|
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 if;
|
||||||
end Main;
|
end Main;
|
||||||
|
|
|
@ -18,10 +18,11 @@ fn main() {
|
||||||
println!("gcd(a, b): {}", gcd(10, 5));
|
println!("gcd(a, b): {}", gcd(10, 5));
|
||||||
println!("factorial(a): {}", factorial(5));
|
println!("factorial(a): {}", factorial(5));
|
||||||
let r = diophantine(1027, 712, 1);
|
let r = diophantine(1027, 712, 1);
|
||||||
|
print!("diophantine(a, b, c): ");
|
||||||
if r.resultExists == 0 {
|
if r.resultExists == 0 {
|
||||||
println!("dupa");
|
println!("there's no solution");
|
||||||
} else {
|
} else {
|
||||||
println!("diophantine(a, b, c): {}, {}", r.n, r.m);
|
println!("{}, {}", r.n, r.m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,11 @@ int main(int argc, char *argv[]) {
|
||||||
printf("gcd(a, b): %u\n", gcd(atol(argv[1]), atol(argv[2])));
|
printf("gcd(a, b): %u\n", gcd(atol(argv[1]), atol(argv[2])));
|
||||||
printf("factorial(a): %u\n", factorial(atol(argv[1])));
|
printf("factorial(a): %u\n", factorial(atol(argv[1])));
|
||||||
Result r = diophantine(atol(argv[1]), atol(argv[2]), atol(argv[3]));
|
Result r = diophantine(atol(argv[1]), atol(argv[2]), atol(argv[3]));
|
||||||
|
printf("diophantine(a, b, c): ");
|
||||||
if (!r.resultExists)
|
if (!r.resultExists)
|
||||||
printf("dupa\n");
|
printf("there's no solution\n");
|
||||||
else
|
else
|
||||||
printf("diophantine(a, b, c): %d, %d\n", r.n, r.m);
|
printf("%d, %d\n", r.n, r.m);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue