#include<iostream> #include<fstream> #include<iomanip> using namespace std; void CreateSquare(int&n); //function to create Magic Square int main(){ ofstream outfile; ifstream infile; outfile.open("output.txt"); infile.open("numbers.txt"); int row, col; cout << "Enter order of the magic box: "; int n = 5; int ms = n * n; int MagicSquare; int classification; cin >> classification; if (classification % 2 == 0){ //classification odd or even cout << "Please enter odd integers only: "; } int m = n/2, s = n-1; for (int i = 1; i <= ms; i++){ cout >> MagicSquare[m][s]; cout >> MagicSquare[0][2] = 1; //Putting the number 1 in top row middle column m++; s--; } for (int row = 0; row < n; row++){ for (int col = 0; col < n; col--) { cout << MagicSquare[m][s]; } } system("pause"); return 0; }
int MagicSquare
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)