Minor fixes for example inputs

This commit is contained in:
Alex Hirsch 2019-01-07 13:24:22 +01:00
parent 2e5a0dbdcc
commit 9a84902011
9 changed files with 73 additions and 80 deletions

View File

@ -16,7 +16,7 @@ int main()
if (Vbat < 0.0) { if (Vbat < 0.0) {
print("Please plug the battery in the right way"); print("Please plug the battery in the right way");
print_nl(); print_nl();
return; return 1;
} }
print("Resistor value: "); print("Resistor value: ");
@ -28,7 +28,7 @@ int main()
if (R < 0.0 || C < 0.0) { if (R < 0.0 || C < 0.0) {
print("Part values must be positive"); print("Part values must be positive");
print_nl(); print_nl();
return; return 1;
} }
print("Time step: "); print("Time step: ");
@ -47,7 +47,7 @@ int main()
if (dt < 0.0 || iter < 0) { if (dt < 0.0 || iter < 0) {
print("Cowardly refusing to go backwards in time"); print("Cowardly refusing to go backwards in time");
print_nl(); print_nl();
return; return 1;
} }
Vc = 0.0; Vc = 0.0;

View File

@ -1,12 +1,10 @@
float kth(float k) float kth(float k)
{ {
return 1.0 / (2.0 * k + 1.0); return 1.0 / (2.0 * k + 1.0);
} }
int main() int main()
{ {
print("Please enter a number: "); print("Please enter a number: ");
float sign; float sign;

View File

@ -1,15 +1,14 @@
void lucas_number (int x, int y, int num){ void lucas_number (int x, int y, int num)
{
int z; int z;
z=0; z=0;
while(num >= x) while(num >= x) {
{
print_int(x); print_int(x);
print(", "); print(", ");
z=x+y; z=x+y;
x=y; x=y;
y=z; y=z;
} }
} }
int main() int main()

View File

@ -1,18 +1,14 @@
float transform_x(float x) float transform_x(float x)
{ {
float fx; float fx;
fx = x; fx = x;
return (-2.0) + ((1.0) - (-2.0)) * (fx / 80.0); return (-2.0) + ((1.0) - (-2.0)) * (fx / 80.0);
} }
float transform_y(float y) float transform_y(float y)
{ {
float fy; float fy;
fy = y; fy = y;
return ((1.0) - ((1.0) - (-1.0)) * (fy / 50.0)) * 2.0; return ((1.0) - ((1.0) - (-1.0)) * (fy / 50.0)) * 2.0;
} }

View File

@ -1,4 +1,5 @@
/* Test booleans and greater/smaller comparisons */ /* Test booleans and greater/smaller comparisons */
void guessNumber(int number, int max) { void guessNumber(int number, int max) {
bool success; bool success;
success = false; success = false;
@ -27,4 +28,3 @@ int main() {
guessNumber(test, 10); guessNumber(test, 10);
return 0; return 0;
} }

View File

@ -1,10 +1,9 @@
int is_prime(int n){ int is_prime(int n)
{
int i; int i;
i = 2; i = 2;
int mod; int mod;
while (i < n/2) while (i < n / 2) {
{
mod = n - (n / i) * i; mod = n - (n / i) * i;
if (mod == 0) { if (mod == 0) {
return 0; return 0;

View File

@ -1,4 +1,5 @@
/* this example sorts 4 numbers like in an sorting network */ /* this example sorts 4 numbers like in an sorting network */
void sort(int a, int b, int c, int d) { void sort(int a, int b, int c, int d) {
int tmp; int tmp;
if(a > c) { tmp = c; c = a; a = tmp; } if(a > c) { tmp = c; c = a; a = tmp; }