Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
  2.  
  3. void show(int* a, int len, int l, int r) {
  4. system("CLS");
  5. int max = a[0], min = a[0];
  6. for (int q = 0; q < len; q++) {
  7. if (a[q] < min) {
  8. min = a[q];
  9. }
  10. if (a[q] > max) {
  11. max = a[q];
  12. }
  13. }
  14. if (min > 0) min = 0;
  15. for (int q = 0; q < (-1) * min + max + 1; q++) {
  16. for (int i = 0; i < len; i++) {
  17. if (i == l || i == r) SetConsoleTextAttribute(console,10);
  18. else SetConsoleTextAttribute(console, 1);
  19. if (q < max) {
  20. if ((max - q) <= a[i]) printf("|");
  21. else printf(" ");
  22. }
  23. else if (q == max) {
  24. printf(".");
  25. }
  26. else {
  27. if (max - q >= a[i]) printf("|");
  28. else printf(" ");
  29. }
  30. }
  31. printf("\n");
  32. }
  33. SetConsoleTextAttribute(console, 1);
  34. system("PAUSE");
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement