I tried solving a problem that goes like this "for a number x that has 3 digits build a square matrix nXn so that on the main diagonal there will be the last digit of the number, in part above the diagonal there will be the second digit of the number and in the bottom part of the diagonal there will be the first digit of the number"
This is the code and it is an infinite cycle can you help me? Thanks.
#include <iostream>
using namespace std;
int n, i, j, a[1001][1001], x;
int main()
{
cin>>x;
cin>>n;
for(i=1; i<=n; i++)
for(j=1; j<=n; i++)
{
if(i==j) a[i][j]=x%10;
else if(i<j) a[i][j]=(x/10)%10;
else if(j>i) a[i][j]=(x/100)%10;
}