I got asked by my teacher to do a chessboard, this is what it looks like when I build it , my problem is that my teacher wants it horizontally like A8, B8, C8, and when I build it it's A8, A7, A6, so I kinda need to swap it but I don't know-how.
#include <iostream>
using namespace std;
int main()
{
for(char i = 65; i < 73; i++)
{
cout << "\n";
cout << i << "8" << " ";
cout << i << "7" << " ";
cout << i << "6" << " ";
cout << i << "5" << " ";
cout << i << "4" << " ";
cout << i << "3" << " ";
cout << i << "2" << " ";
cout << i << "1" << " ";
cout << "\n";
}
}
You have to print letters from A to H on each line. Also, printing numbers is much easier with a loop too.
for(int i = 8; i >= 1; i--)
{
for(char c = 'A'; c <= 'H'; c++)
{
std::cout << c << i << " ";
}
std::cout << '\n';
}