Advertisement
Guest User

Untitled

a guest
Oct 20th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(int argc, char** argv) {
  5. //Declare Variables
  6. int X;
  7. int i=1;
  8.  
  9. cout << "Input a positive number." << endl;
  10. cin >> X;
  11. cout << endl;
  12.  
  13. //Input Validation
  14. while (X<0) {
  15. cout << "Invalid entry. Enter a number greater than 0." << endl;
  16. cin >> X ;
  17. }
  18. int A = X;
  19. //This section makes the X
  20. for (int row=1; row<=A; row++, X--) {
  21.  
  22. for (int col=1; col<=A; col++){
  23. if ((row ==(A/2)+1) && (col == (A/2)+1)){
  24. cout << X;
  25. }
  26. else if((row==col)||(col==(A+1)-row)) {
  27. cout << X;
  28.  
  29. }
  30.  
  31. else cout << " ";
  32. }
  33. cout << endl;
  34. }
  35.  
  36.  
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement