Advertisement
meowmeow_t_ch

tupu tupu tupu

Nov 16th, 2020 (edited)
1,981
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <locale.h>
  4.  
  5. inline void gwiazdki() {
  6.     int i;
  7.     for (i = 1; i <= 120; i++)
  8.     {
  9.         printf("*");
  10.     }
  11. }
  12.  
  13. void autor() {
  14.     printf("Autor programu: Teresa Chrzan \n\n");
  15. }
  16.  
  17. float wynikdz(float a, float b) {
  18.     float iloraz;
  19.     iloraz = a / b;
  20.     return iloraz;
  21. }
  22.  
  23.  
  24. int main()
  25. {
  26.     setlocale(LC_CTYPE, "Polish");
  27.     float a, b, wynik, tab[51];
  28.     int res = 1, ilepow = 0;
  29.  
  30.  
  31.         gwiazdki();
  32.         autor();
  33.         gwiazdki();
  34.  
  35. do {
  36.     if (ilepow > 51) {
  37.         printf("Niemożliwa dalsza iteracja z uwagi na ograniczony rozmiar tablicy!");
  38.         break;
  39.     }
  40.         printf("\n");
  41.  
  42.         printf("Dzielenie liczb \n");
  43.  
  44.         printf("podaj dzielną: ");
  45.         scanf_s("%f", &a);
  46.  
  47.         printf("podaj dzielnik: ");
  48.         scanf_s("%f", &b);
  49.  
  50.         if (b != 0)
  51.         {
  52.             if (ilepow < 51) {
  53.                 wynik = wynikdz(a, b);
  54.                 printf("ILORAZ wynosi: ");
  55.                 printf("%f", wynik);
  56.                 tab[ilepow] = wynik;
  57.             }
  58.         }
  59.         else {
  60.             printf("\n");
  61.             printf("BŁĄD DZIELENIA PZRZEZ ZERO !!!");
  62.             system("pause");
  63.             return 0;
  64.         }
  65.  
  66.         printf("\n Czy wykonać cały program ponownie (t/n)? ");
  67.         scanf_s(" %c", &res, 1);
  68.  
  69.         ilepow++;
  70.  
  71.     } while (res == 't');
  72.  
  73.     if (res == 'n')
  74.     {
  75.  
  76.         if (ilepow < 51)
  77.         {
  78.             printf("\n");
  79.             printf("Wszystkie wyniki dzielenia - kolejno: ");
  80.             for (int i = 0; i < ilepow; i++) {
  81.                 printf(" %f  ", tab[i]);
  82.             }
  83.         }
  84.     }
  85.     else
  86.     {
  87.         printf("\n Musisz wpisać \'t\' albo \'n\', program zostanie zatrzymany! \n");
  88.        
  89.     }
  90.  
  91.     return 0;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement