#include
#include
#include
#include
using namespace std;
int main(int argc, char** argv)
{
srand(time(0));
for (int i = 0; i < 100; ++i){
int n = (rand() * rand()) % 0xFFFFFF;
cout << setfill('0') << setw(6)
<< right << uppercase << hex
<< n << endl;
}
return 0;
}
This program lists 100 random Colors. Use functions to remove any nested loops (loops within loops) that are in your code.
#include
#include
using namespace std;
int main(int argc, char** argv) {
for (int i = 0; i < 100; ++i) {
for (int j = 0; j < 6; ++j) {
int n = rand() % 16;
if (n == 15) cout << 'F';
else if (n ==14) cout << 'E';
else if (n ==13) cout << 'D';
else if (n ==12) cout << 'C';
else if (n ==11) cout << 'B';
else if (n ==10) cout << 'A';
else cout << n;
}
cout << endl;
}
return 0;
}
please help solve. thank you