Advertisement
Guest User

LABY

a guest
Nov 12th, 2019
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3.  
  4. void WaitForUser()
  5. {
  6. printf("press Enter\n");
  7. getchar();
  8. }
  9.  
  10. void Wait(double number)
  11. {
  12. int t;
  13. t = clock();
  14. while ((clock() - t) < number * CLOCKS_PER_SEC) {
  15. /*pass*/
  16. };
  17. }
  18.  
  19. int main()
  20. {
  21. printf("0123456789 -- tab\n");
  22. printf("\t*\n");
  23. printf("0\t*\n");
  24. printf("01\t*\n");
  25. printf("012\t*\n");
  26. printf("0123\t*\n");
  27. printf("01234\t*\n");
  28. printf("012345\t*\n");
  29. printf("0123456\t*\n");
  30. printf("01234567\t*\n");
  31. printf("012345678\t*\n");
  32. printf("0123456789\t*\n");
  33. printf("0123456789A\t*\n");
  34. WaitForUser();
  35.  
  36. char* names[] = { "Ala","Ela","Ola","Ula","Bolek","Lolek","Reksio" };
  37. int results[] = { 10,40,20,30,20,0,40 };
  38. printf("+-------+-------+-------+\n");
  39. printf("name\t|points\t|[%%]\t|\n");
  40. printf("+-------+-------+-------+\n");
  41. for (int i = 0; i < sizeof(names) / sizeof(names[0]); ++i)
  42. {
  43. printf("|%s\t|%d\t|%d\t|\n", names[i], results[i], results[i] * 5 / 2);
  44. };
  45. printf("+-------+-------+-------+\n");
  46. WaitForUser();
  47.  
  48. printf("old string, new line at the end\n");
  49. printf("new string\n");
  50. printf("----------\n");
  51. printf("old string, carriage return\r");
  52. printf("new string\n");
  53. printf("----------\n");
  54. WaitForUser();
  55.  
  56. printf("Countdown: ");
  57. for (int i = 0; i <= 100; i++) {
  58. Wait(0.1);
  59. printf("%3d%%\b\b\b\b", i);
  60. };
  61. printf("\n");
  62. WaitForUser();
  63. for (int i = 0; i <= 100; i++)
  64. {
  65. Wait(0.1);
  66. printf("Second countdown: %3d%%\r", i);
  67. };
  68. printf("\n");
  69. return 0;
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement