Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- zad1/
- #include <stdio.h>
- void progowa(int, int);
- int main()
- {
- int x, y;
- for(;;)
- {
- printf("Podaj dwie liczby:\n");
- scanf("%d%d", &x, &y);
- progowa(x,y);
- }
- return 0;
- }
- void progowa(int x, int y)
- {
- int iloczyn=x*y;
- if(iloczyn > 100) printf("a\n");
- else if(iloczyn < 100) printf("b\n");
- else printf("c\n");
- }
- zad2/
- #include <stdio.h>
- int pobierz(float, float, float);
- int main(void)
- {
- float a, b, c;
- for(;;)
- {
- printf("Wypisz wspolczynniki a, b, c w tej kolejnosci:\n");
- scanf("%f%f%f", &a, &b, &c);
- printf("Rownanie %f x*x + %f x + %f ma: ", a, b, c);
- if(pobierz(a, b, c) == 2) printf("2");
- else if(pobierz(a, b, c) == 1) printf("1");
- else printf("0");
- printf(" pierwiastki\n");
- }
- return 0;
- }
- int pobierz(float a, float b, float c)
- {
- int delta = (b*b)-(4*a*c);
- if(delta > 0) return 2;
- else if(delta == 0) return 1;
- else return 0;
- }
- zad3/
- #include <stdio.h>
- void sort(int tab[], int ile);
- int main(void)
- {
- int ile, i;
- printf("Podaj ilosc liczb ktore chcesz wpisac:\n");
- scanf("%d", &ile);
- printf("Wypisz je:\n");
- int tab[ile];
- for(i = 0; i < ile; i++) scanf("%d", &tab[i]);
- printf("Po posortowaniu:\n");
- sort(tab, ile);
- for(i = 0; i < ile; i++) printf("%d\n", tab[i]);
- return 0;
- }
- void sort(int tab[], int ile)
- {
- int i, j, bufor;
- for(i = 0; i < ile; i++)
- {
- for(j = 1; j < ile-i; j++)
- {
- if(tab[j] > tab[j-1])
- {
- bufor = tab[j-1];
- tab[j-1] = tab[j];
- tab[j] = bufor;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment