fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int T, n;
  5. scanf("%d", &T);
  6. for (int t = 0; t < T; t++) {
  7. scanf("%d", &n);
  8. for (int i = n; i >= 1; i--) {
  9. if (i == n) {
  10. for (int j = 0; j < n; j++) {
  11. printf("*");
  12. }
  13. } else if (i == 1) {
  14. printf("*");
  15. } else if (i == 2) {
  16. printf("**");
  17. } else {
  18. printf("*");
  19. for (int j = 0; j < i - 2; j++) {
  20. printf(" ");
  21. }
  22. printf("*");
  23. }
  24. printf("\n");
  25. }
  26. if (t != T - 1) {
  27. printf("\n");
  28. }
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 5312KB
stdin
3
5 3 7
stdout
*****
*  *
* *
**
*

***
**
*

*******
*    *
*   *
*  *
* *
**
*