Array Self Continuing

I just made this code...
but I want the "tablas" array to continue to write on itself
without me having to write 100 times cout<<tablas[8]<<endl;
is there a way to do that??

here is the code
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
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <iomanip>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;
string tablas[1000];
int main()
{
for(int a=1;a<11;a++)
    {
        for(int k=1;k<11;k++)
        {
            std::string a2;
            std::stringstream outa;
            outa << a;
            a2 = outa.str();

            std::string k2;
            std::stringstream outk;
            outk << k;
            k2 = outk.str();

            string result;
            std::string result2;
            std::stringstream outres;
            outres << a*k;
            result2 = outres.str();

            string times="x";
            string equalsign="=";
            int keepnumber=((a-1)*10)+k;
            tablas[keepnumber]=a2+times+k2+equalsign+result2;
        }
    }
    cout<<tablas[8]<<endl;
    cout<<tablas[2]<<endl;
    cout<<tablas[30]<<endl;
    cout<<tablas[45]<<endl;
    return 0;
}
Last edited on
1
2
3
4
for(int i = 0; i < 1000; i++)
{
  cout << tablas[i] << endl;
}
thanks Texan40
Never cross my mind...
Guess I have to rest a little bit... XD
Topic archived. No new replies allowed.