fork download
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5.  
  6.  
  7. int pocet = 0;
  8. int a;
  9. int klad = 0;
  10. int zapor = 0;
  11. int sud = 0;
  12. int lich = 0;
  13. int min = 10000;
  14. int max = -10000;
  15. int sum = 0;
  16.  
  17. while(scanf("%d", &a) == 1)
  18. {
  19. sum+=a;
  20.  
  21. if((a<-10000) | (a>10000))
  22. {
  23. printf("\nError: Vstup je mimo interval!\n");
  24. return 100;
  25. }
  26.  
  27.  
  28. if(pocet == 0)
  29. {
  30. printf("%d", a);
  31. }
  32. else
  33. {
  34. printf(", %d", a);
  35. }
  36.  
  37. if(a%2==0)
  38. {
  39. sud++;
  40. }
  41. else
  42. {
  43. lich++;
  44. }
  45.  
  46.  
  47. if(a > max)
  48. {
  49. max = a;
  50. }
  51. if(a < min)
  52. {
  53. min = a;
  54. }
  55.  
  56.  
  57. if(a<0)
  58. {
  59. zapor++;
  60. }
  61. else
  62. {
  63. klad++;
  64. }
  65.  
  66. pocet ++;
  67.  
  68. }
  69.  
  70.  
  71. printf("\nPocet cisel: %d\n", pocet);
  72. printf("Pocet kladnych: %d\n", klad);
  73. printf("Pocet zapornych: %d\n", zapor);
  74. printf("Procento kladnych: %.2f\n", (float)klad/pocet*100);
  75. printf("Procento zapornych: %.2f\n", (float)zapor/pocet*100);
  76. printf("Pocet sudych: %d\n", sud);
  77. printf("Pocet lichych: %d\n", lich);
  78. printf("Procento sudych: %.2f\n", (float)sud/pocet*100);
  79. printf("Procento lichych: %.2f\n", (float)lich/pocet*100);
  80. printf("Prumer: %.2f\n", (float)sum/pocet);
  81. printf("Maximum: %d\n", max);
  82. printf("Minimum: %d\n", min);
  83. return 0;
  84. }
  85.  
  86.  
  87.  
Success #stdin #stdout 0s 4276KB
stdin
Standard input is empty
stdout
Pocet cisel: 0
Pocet kladnych: 0
Pocet zapornych: 0
Procento kladnych: -nan
Procento zapornych: -nan
Pocet sudych: 0
Pocet lichych: 0
Procento sudych: -nan
Procento lichych: -nan
Prumer: -nan
Maximum: -10000
Minimum: 10000