olekturbo

newfunkcje

Nov 28th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. zad1/
  2. #include <stdio.h>
  3.  
  4. void progowa(int, int);
  5.  
  6. int main()
  7. {
  8. int x, y;
  9.  
  10. for(;;)
  11. {
  12. printf("Podaj dwie liczby:\n");
  13. scanf("%d%d", &x, &y);
  14. progowa(x,y);
  15. }
  16. return 0;
  17. }
  18.  
  19. void progowa(int x, int y)
  20. {
  21. int iloczyn=x*y;
  22. if(iloczyn > 100) printf("a\n");
  23. else if(iloczyn < 100) printf("b\n");
  24. else printf("c\n");
  25. }
  26.  
  27. zad2/
  28. #include <stdio.h>
  29.  
  30. int pobierz(float, float, float);
  31.  
  32. int main(void)
  33. {
  34. float a, b, c;
  35. for(;;)
  36. {
  37. printf("Wypisz wspolczynniki a, b, c w tej kolejnosci:\n");
  38. scanf("%f%f%f", &a, &b, &c);
  39.  
  40. printf("Rownanie %f x*x + %f x + %f ma: ", a, b, c);
  41.  
  42. if(pobierz(a, b, c) == 2) printf("2");
  43. else if(pobierz(a, b, c) == 1) printf("1");
  44. else printf("0");
  45.  
  46. printf(" pierwiastki\n");
  47. }
  48. return 0;
  49. }
  50.  
  51. int pobierz(float a, float b, float c)
  52. {
  53. int delta = (b*b)-(4*a*c);
  54. if(delta > 0) return 2;
  55. else if(delta == 0) return 1;
  56. else return 0;
  57. }
  58. zad3/
  59. #include <stdio.h>
  60.  
  61. void sort(int tab[], int ile);
  62.  
  63. int main(void)
  64. {
  65. int ile, i;
  66. printf("Podaj ilosc liczb ktore chcesz wpisac:\n");
  67. scanf("%d", &ile);
  68. printf("Wypisz je:\n");
  69. int tab[ile];
  70. for(i = 0; i < ile; i++) scanf("%d", &tab[i]);
  71. printf("Po posortowaniu:\n");
  72. sort(tab, ile);
  73. for(i = 0; i < ile; i++) printf("%d\n", tab[i]);
  74. return 0;
  75. }
  76.  
  77. void sort(int tab[], int ile)
  78. {
  79. int i, j, bufor;
  80. for(i = 0; i < ile; i++)
  81. {
  82. for(j = 1; j < ile-i; j++)
  83. {
  84. if(tab[j] > tab[j-1])
  85. {
  86. bufor = tab[j-1];
  87. tab[j-1] = tab[j];
  88. tab[j] = bufor;
  89. }
  90. }
  91. }
  92. }
Add Comment
Please, Sign In to add comment