Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(int argc, char** argv) {
- //Declare Variables
- int X;
- int i=1;
- cout << "Input a positive number." << endl;
- cin >> X;
- cout << endl;
- //Input Validation
- while (X<0) {
- cout << "Invalid entry. Enter a number greater than 0." << endl;
- cin >> X ;
- }
- int A = X;
- //This section makes the X
- for (int row=1; row<=A; row++, X--) {
- for (int col=1; col<=A; col++){
- if ((row ==(A/2)+1) && (col == (A/2)+1)){
- cout << X;
- }
- else if((row==col)||(col==(A+1)-row)) {
- cout << X;
- }
- else cout << " ";
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement