Compare commits
11 commits
Author | SHA1 | Date | |
---|---|---|---|
86979c9d54 | |||
5583e2ddb8 | |||
870de20e20 | |||
3d6877c822 | |||
97dbc9fb7b | |||
16e566bfa0 | |||
5fa84b93fb | |||
858990447e | |||
array-in-a-matrix | 3bb69b067b | ||
56fa33af33 | |||
8180560937 |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -53,3 +53,4 @@ dkms.conf
|
||||||
|
|
||||||
# quadratic executable
|
# quadratic executable
|
||||||
quadratic
|
quadratic
|
||||||
|
quadratic-tui
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
# quadratic
|
# quadratic
|
||||||
|
|
||||||
Simple cli calculator that computes real and complex roots of a quadratic.
|
Simple cli calculator that computes real and complex roots of a quadratic.
|
||||||
<br>
|
|
||||||
Make a project do one thing good rather than do alot that isn't. I learned from my past projects and the best way to code is to KISS.
|
|
||||||
|
|
10
makefile
10
makefile
|
@ -1,2 +1,12 @@
|
||||||
|
DESTDIR ?= /usr/bin
|
||||||
|
|
||||||
all:
|
all:
|
||||||
gcc quadratic.c -lm -Wall -O3 -o "quadratic"
|
gcc quadratic.c -lm -Wall -O3 -o "quadratic"
|
||||||
|
cp quadratic-tui.sh quadratic-tui
|
||||||
|
|
||||||
|
install:
|
||||||
|
install -Dm755 quadratic $(DESTDIR)/
|
||||||
|
install -Dm755 quadratic-tui $(DESTDIR)/
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -f $(DESTDIR)/{quadratic,quadratic-tui}
|
||||||
|
|
|
@ -4,7 +4,7 @@ ARG_A=$(whiptail --inputbox "Please enter the value for \"a\":" 10 50 --title "Q
|
||||||
|
|
||||||
exitstatus=$?
|
exitstatus=$?
|
||||||
if [ $exitstatus != 0 ]; then
|
if [ $exitstatus != 0 ]; then
|
||||||
echo "User canceled input."
|
echo "User cancelled input."
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ ARG_B=$(whiptail --inputbox "Please enter the value for \"b\":" 10 50 --title "Q
|
||||||
|
|
||||||
exitstatus=$?
|
exitstatus=$?
|
||||||
if [ $exitstatus != 0 ]; then
|
if [ $exitstatus != 0 ]; then
|
||||||
echo "User canceled input."
|
echo "User cancelled input."
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ ARG_C=$(whiptail --inputbox "Please enter the value for \"c\":" 10 50 --title "Q
|
||||||
|
|
||||||
exitstatus=$?
|
exitstatus=$?
|
||||||
if [ $exitstatus != 0 ]; then
|
if [ $exitstatus != 0 ]; then
|
||||||
echo "User canceled input."
|
echo "User cancelled input."
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -9,7 +9,7 @@ int main(int num_arg, char **args)
|
||||||
|
|
||||||
if (num_arg <= 1)
|
if (num_arg <= 1)
|
||||||
{
|
{
|
||||||
system("/bin/sh /home/linux/Documents/Projects/quadratic/quadratic-tui"); //! need a better solution
|
system("quadratic-tui"); // make sure it is in PATH along with "quadratic" bin
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ int main(int num_arg, char **args)
|
||||||
double real_part = (-num_B) / (2 * num_A);
|
double real_part = (-num_B) / (2 * num_A);
|
||||||
double imaginary_part = sqrt(radical * -1.0) / (2 * num_A);
|
double imaginary_part = sqrt(radical * -1.0) / (2 * num_A);
|
||||||
|
|
||||||
printf("%f+%fi %f-%fi\n", real_part, imaginary_part, real_part, imaginary_part);
|
printf("%g+%gi\t %g-%gi\n", real_part, imaginary_part, real_part, imaginary_part);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ int main(int num_arg, char **args)
|
||||||
double zero_1_ptr = numerator_1 / (2 * num_A);
|
double zero_1_ptr = numerator_1 / (2 * num_A);
|
||||||
double zero_2_ptr = numerator_2 / (2 * num_A);
|
double zero_2_ptr = numerator_2 / (2 * num_A);
|
||||||
|
|
||||||
printf("%f %f\n", zero_1_ptr, zero_2_ptr);
|
printf("%g\t %g\n", zero_1_ptr, zero_2_ptr);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue