Advertisement
llvlleo1810

Dạng bài tập về vẽ hình bằng số

Apr 18th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. Viết chương trình nhập vào n và in ra hình theo quy luật
  2. INPUT
  3. 5
  4. OUTPUT
  5. 5 5 5 5 5
  6. 5 4 4 4 4
  7. 5 4 3 3 3
  8. 5 4 3 2 2
  9. 5 4 3 2 1
  10. ---------------------------
  11. #include<stdio.h>
  12. int main(){
  13. int n;
  14. scanf("%d", &n);
  15. int gt=0;
  16. for(int i=1;i<=n;i++)
  17. {
  18. for(int j=1;j<=n;j++)
  19. {
  20. gt++;
  21. if(j>i) printf("%d ",n-i+1);
  22. else printf("%d ",n-j+1);
  23. }
  24.  
  25. printf("\n");
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement