Hello guys and girls.
My question is simple one but I have no answer. Below you can see my C++ code - it is a little bit big but simple - when I run the code with //std::cout<<yy<<endl; (commented)
it run less than 1 second, when I un-comment that line it runs about 2 minutes (I speak about Release because in Debug it run more time). Please pay attention that that line produce only few output lines (so the problem is not that the program have to call "cout" too many times) Thank you all. Here is my code:
#include <cstdlib>
#include <iostream>
using namespace std;
struct cell {
int x;
int y;
};
int main(int argc, char** argv) {
cell vector[8];
unsigned long int yy=0;
for (int aaa = 0; aaa < 8; aaa++) {
vector[0].x = aaa;
for (int aab = 0; aab < 8; aab++) {
vector[0].y = aab;
for (int aac = 0; aac < 8; aac++) {
vector[1].x = aac;
for (int aad = 0; aad < 8; aad++) {
vector[1].y = aad;
for (int aae = 0; aae < 8; aae++) {
vector[2].x = aae;
for (int aaf = 0; aaf < 8; aaf++) {
vector[2].y = aaf;
for (int aag = 0; aag < 8; aag++) {
vector[3].x = aag;
for (int aah = 0; aah < 8; aah++) {
vector[3].y = aah;
for (int aai = 0; aai < 8; aai++) {
vector[4].x = aai;
for (int aaj = 0; aaj < 8; aaj++) {
vector[4].y = aaj;
for (int aak = 0; aak < 8; aak++) {
vector[5].x = aak;
for (int aal = 0; aal < 8; aal++) {
vector[5].y = aal;
yy++;
if(yy%10000000000==0){
vector[5].y = aal-1;
//std::cout<<yy<<endl;
}
}
}
}
}
}
}
}
}
}
}
}
}
std::cout<<yy<<endl;
std::cout<<vector[5].y<<endl;
return 0;
}