Created
March 10, 2019 08:21
-
-
Save AndrewS097/2b65111d5b5d12c1de3498f80e7a8a49 to your computer and use it in GitHub Desktop.
ACM Problem Solving for base of 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
int main(){ | |
int runs, input, output; | |
int base=1; | |
int test_number= pow(215, 4); | |
//holds input numbers | |
cout << "How many inputs: " << endl; | |
cin>> runs; | |
//executes the loop of the entered amount of numbers | |
for (int i=0; i<=runs-1;i++){ | |
cout << "Enter a value: " << endl; | |
cin>> input; | |
//runs the input through the mod test untill 3 is the end of the base | |
if (input >=3){ | |
while(input%base !=3){ | |
base++; | |
if (base>=test_number)//exits when there is no base | |
{ | |
break;} | |
} | |
if (base>=test_number) | |
{cout << "No such base" << endl; | |
base=1;} | |
else {cout <<"The base is "<< base << endl; | |
base=1; | |
} | |
} | |
if (input < 3){ | |
cout << "No such base" << endl; | |
base=1; | |
} | |
} | |
cout << "Program is complete" << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment