When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
3 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
Here is the code i started (the table)
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
const int size = 7; // Table size
const int width = 4; // Width of each cell
for(int i=1;i<=12;i++){
cout<<i<<endl;
// Print column headers
cout << setw(width) << " ";
for (int col = 1; col <= size; ++col) {
cout << "|" << setw(width) << col;
}
cout << endl;
// Print line separator
cout << setw(width) << " ";
for (int col = 1; col <= size; ++col) {
cout << "+" << setw(width) << setfill('-') << "----";
}
cout << setfill(' ') << endl;
// Print table rows
for (int row = 1; row <= size; ++row) {
// Print row header
cout << setw(width) << row;
// Print row values
for (int col = 1; col <= size; ++col) {
cout << "|" << setw(width) << row * col;
}
cout << endl;
// Print line separator
if (row != size) {
cout << setw(width) << " ";
for (int col = 1; col <= size; ++col) {
cout << "+" << setw(width) << setfill('-') << "----";
}
cout << setfill(' ') << endl;
}
}
cout<<endl;
}
return 0;
}
This question is being automatically marked as stale.
If your question has been answered, type !solved.
If your question is not answered feel free to bump the post or re-ask.
Take a look at !howto ask for tips on improving your question.