declare array that has element of 1 to 999999999 c++
Feb 22, 2015 at 2:29pm UTC
i've been using dev C++, and im struggling with how to declare array element with 1-999999999.
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
#include<iostream>
using namespace std;
int main()
{
int x,y;
char *ans[1000000000] = {"1" -"999999999" };
//I don't know how to declare 1-999999999.
cin>x;
cin>y;
switch (oper)
{
case '+' : an = num1 + num2;
cout<<an<<endl;
outtextxy(x,y,an[ans]);
break ;
case '-' : an= num1 - num2;
cout<<an<<endl;
outtextxy(x,y,an[ans]);
break ;
case '*' : an = num1 * num2;
cout<<an<<endl;
outtextxy(x,y,an[ans]);
break ;
case '/' : if (num2 == 0)
cout << "Not Divisible by 0! Start Again!" << endl;
else an = num1 / num2;
cout<<an<<endl;
outtextxy(x,y,an[ans]);
break ;
default : cout << "Bad operator '" << oper << "'" << endl;
}
}
}
if (oper=='+' || oper=='-' || oper=='*' || oper=='/' )
{
goto LOOP1;
}
getch ();
return 0;
}
Feb 22, 2015 at 2:43pm UTC
First of all your array would take up about 16GB of memory.
Why would you need that? Generate a string representation of number when nessesary, there is no need to cache it.
Feb 22, 2015 at 2:53pm UTC
thnx for idea sir.
Topic archived. No new replies allowed.