Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int szescian(int a);
- int walec(int a, int r);
- void punkt(float x, float y);
- void wyplata();
- float kalkulator(char znak, float x, float y);
- void czySamo(char litera);
- void suma(int n);
- void szlaczek();
- void ileDodatnich();
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- int main(int argc, char *argv[]) {
- int wybor, a, r, n;
- float x,y;
- char znak, litera;
- printf("Menu\n");
- printf("1.Szescian\n");
- printf("2.Walec\n");
- printf("3.Punkt\n");
- printf("4.Wyplata\n");
- printf("5.Kalkulator\n");
- printf("6.Czy samogloska\n");
- printf("7.Suma\n");
- printf("8.Szlaczek\n");
- printf("9.Ile dodatnich\n");
- printf("Twoj wybor: ");
- scanf("%d",&wybor);
- switch(wybor)
- {
- case 1:
- printf("Podaj bok szczescianu: ");
- scanf("%d",&a);
- szescian(a);break;
- case 2:
- printf("Podaj promien podstawy: ");
- scanf("%d",&r);
- printf("Podaj wysokosc walca: ");
- scanf("%d",&a);
- walec(a,r);break;
- case 3:
- printf("Podaj x: ");
- scanf("%f",&x);
- printf("Podaj y: ");
- scanf("%f",&y);
- punkt(x,y);break;
- case 4:
- wyplata();break;
- case 5:
- printf("Podaj znak dzialania\n");
- fflush(stdin);
- scanf("%c",&znak);
- printf("Podaj 1 liczbe\n");
- scanf("%f",&x);
- printf("Podaj 2 liczbe\n");
- scanf("%f",&y);
- printf("wynik twojego dzialania wynosi %0.2f", kalkulator(znak, x, y));break;
- case 6:
- printf("Podaj litere: ");
- fflush(stdin);
- scanf("%c",&litera);
- czySamo(litera);break;
- case 7:
- printf("Podaj ilosc liczb: ");
- scanf("%d",&n);
- suma(n);break;
- case 8:
- szlaczek();break;
- case 9:
- ileDodatnich();break;
- default:
- printf("Zly wybor\n");
- }
- return 0;
- }
- int szescian(int a)
- {
- int pole;
- pole=a*a*a;
- printf("Pole wynosi %d",pole);
- }
- int walec(int a, int r)
- {
- int obj;
- obj=3.14*r*r*a;
- printf("Obj walca wynosi %d",obj);
- }
- void punkt(float x, float y)
- {
- if((x>=-1) && (x<=1) && (y>=-1) && (y<=1))
- printf("Punkty naleza do zamalowanego obszaru");
- else
- printf("Blad");
- }
- void wyplata()
- {
- int p, s;
- float pensja;
- printf("Podaj pensje: ");
- scanf("%d",&p);
- printf("Podaj lata stazu: ");
- scanf("%d",&s);
- if (s<5)
- {
- printf("Dodatek sie nie nalezy, pensja wynosi %d",p);
- }
- else if ((s>=5) && (s<=10))
- {
- printf("Dodatek wynosi %d procent\n",s);
- pensja=s/100.*p+p;
- printf("Pensja wynosi %0.2f",pensja);
- }
- else if (s>10)
- {
- printf("Dodatek wynosi 15%\n");
- pensja=1.15*p;
- printf("Pensja wynosi %0.2f",pensja);
- }
- }
- float kalkulator(char znak, float x, float y)
- {
- switch(znak)
- {
- case '-':
- return x-y;break;
- case '+':
- return x+y;break;
- default:
- printf("Bledny znak\n");break;
- }
- }
- void czySamo(char litera)
- {
- switch(litera)
- {
- case 'a':
- case 'A':
- case 'e':
- case 'E':
- case 'i':
- case 'I':
- case 'o':
- case 'O':
- case 'u':
- case 'U':
- case 'y':
- case 'Y':
- printf("Samogloska\n");break;
- default:
- printf("Wspolgloska\n");break;
- }
- }
- void suma(int n)
- {
- int i=1;
- int suma=0;
- int a;
- while(i<=n)
- {
- printf("Podaj liczbe: ");
- scanf("%d",&a);
- printf("\n");
- suma=suma+a;
- printf("Suma wynosi: %d\n",suma);
- i++;
- }
- printf("Suma wynosi: %d", suma);
- }
- void szlaczek()
- {
- int g;
- int i; //ilosc gwiazdek w szlaczku
- int wiersz; //ilosc wierszy szlaczku
- printf("Podaj ilosc gwiazdek w szlaczku: ");
- scanf("%d",&i);
- printf("Podaj ilosc wierszy szlaczku: ");
- scanf("%d",&wiersz);
- while (wiersz>=1)
- {
- for (g=1; g<=i; g++)
- printf("*");
- wiersz--;
- printf("\n");
- }
- }
- void ileDodatnich()
- {
- int x=1;
- int i=0;
- printf("Podaj ciag liczb zakonczonych zerem\n");
- while(x=!0)
- {
- if(x>0)
- {
- i++;
- printf("Podaj kolejna liczbe ");
- scanf("%d",&x);
- printf("%d",i);
- } else if (x<0)
- {
- printf("Podaj kolejna liczbe ");
- scanf("%d",&x);
- printf("%d",i);
- } else
- printf("Jest %d liczb dodatnich",i);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement