From 27ee3082f9c017823b0f11dc79be1ae1e0e35be9 Mon Sep 17 00:00:00 2001 From: jstmax! <87650746+MaxWasTakenYT@users.noreply.github.com> Date: Thu, 17 Oct 2024 17:18:39 +0000 Subject: Update xsc_debug.cpp --- xsc_debug.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/xsc_debug.cpp b/xsc_debug.cpp index 58fc236..27a8d88 100644 --- a/xsc_debug.cpp +++ b/xsc_debug.cpp @@ -3,23 +3,39 @@ #include using namespace std; -int usage() { +void usage() { // Prints usage message (help) system("figlet XSC | lolcat"); cout << "\neXtremelySimpleCalculator usage:\n" << "`xsc --help` for help\n" << "`xsc <(+|-|*|/|%|^)> ` for basic operation calculating\n" << "`xsc -r|--sqrt ` for square root calculation\n"; - return 0; } int main(int argc, char* argv[]) { // main::Calculations(); - if (argv[1] == "-r" || argv[1] == "--sqrt") { - int result = sqrt(atoi(argv[2])); + if (argv[2][0] == '+') { + cout << atof(argv[1]) + atof(argv[3]); + } + else if (argv[2][0] == '-') { + cout << atof(argv[1]) - atof(argv[3]); + } + else if (argv[2][0] == '*') { + cout << atof(argv[1]) * atof(argv[3]); + } + else if (argv[2][0] == '/') { + cout << atof(argv[1]) / atof(argv[3]); + } + else if (argv[2][0] == '%') { + cout << fmod(atof(argv[1]), atof(argv[3])); + } + else if (argv[2][0] == '^') { + cout << pow(atof(argv[1]), atof(argv[3])); } else { - int result = atoi(argv[1]), argv[2], atoi(argv[3]); + cout << "invalid operator!\n"; + usage(); + return 0; } // main::Handling(); @@ -27,6 +43,7 @@ int main(int argc, char* argv[]) { usage(); return 0; } + /* else if (argc > 4) { cout << "too many arguments!\n"; usage(); @@ -37,4 +54,5 @@ int main(int argc, char* argv[]) { usage(); return 1; } + */ } -- cgit v1.3.1