ala russe multiplication program ! hard
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#include <iostream>
using namespace std;
int main(){
int firstNumber = 0 , secondNumber = 0;
int firstRemain = 0 , secondRemain = 0;
int firstResult = 0 , secondResult = 0;
int *firstDivide = NULL , *secondMultiply = NULL;
int firstarray = 0 , secondarray = 0;
int total = 0;
firstDivide = new int[];
secondMultiply = new int[];
cout << "Enter first number : ";
cin >> firstNumber;
while( !cin.good() ){
cin.clear();
cin.ignore(100,'\n');
cout << "Cannot enter character ! Please re-enter ! " << endl;
cout << "Enter first number : ";
cin >> firstNumber;
}
cout << "Enter second number : ";
cin >> secondNumber;
while( !cin.good() ){
cin.clear();
cin.ignore(100,'\n');
cout << "Cannot enter character ! Please re-enter ! " << endl;
cout << "Enter second number : ";
cin >> secondNumber;
}
firstDivide[firstarray] = firstNumber;
firstarray++;
secondMultiply[secondarray] = secondNumber;
secondarray++;
firstResult = firstNumber / 2;
secondResult = secondNumber * 2;
firstDivide[firstarray] = firstResult;
firstarray++;
secondMultiply[secondarray] = secondResult;
secondarray++;
while( firstDivide[firstarray-1] / 2 < 1 ){
firstResult = 0;//Reset back firstResult = 0
firstResult = firstDivide[firstarray - 1 ] / 2;
firstDivide[firstarray] = firstResult;
firstarray++;
secondResult = 0;//reset back secondResult = 0;
secondResult = secondMultiply[secondarray - 1] * 2;
secondMultiply[secondarray] = secondResult;
secondarray++;
}
for( int i = 0 ; i < firstarray ; i++ ){
if( firstDivide[i] % 2 != 0 ){
total += secondMultiply[i];
}
}
cout << "Answer for multiplcation for ala russe is : " << total << endl;
system( "pause" );
return 0;
}
|
what im doing wrong?
someone please help me.. going crazy
What are you trying to do? What is ala russe?
Topic archived. No new replies allowed.