Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.97 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int szescian(int a);
  4. int walec(int a, int r);
  5. void punkt(float x, float y);
  6. void wyplata();
  7. float kalkulator(char znak, float x, float y);
  8. void czySamo(char litera);
  9. void suma(int n);
  10. void szlaczek();
  11. void ileDodatnich();
  12.  
  13. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  14.  
  15. int main(int argc, char *argv[]) {
  16.  
  17. int wybor, a, r, n;
  18. float x,y;
  19. char znak, litera;
  20. printf("Menu\n");
  21. printf("1.Szescian\n");
  22. printf("2.Walec\n");
  23. printf("3.Punkt\n");
  24. printf("4.Wyplata\n");
  25. printf("5.Kalkulator\n");
  26. printf("6.Czy samogloska\n");
  27. printf("7.Suma\n");
  28. printf("8.Szlaczek\n");
  29. printf("9.Ile dodatnich\n");
  30. printf("Twoj wybor: ");
  31. scanf("%d",&wybor);
  32.  
  33. switch(wybor)
  34. {
  35. case 1:
  36. printf("Podaj bok szczescianu: ");
  37. scanf("%d",&a);
  38. szescian(a);break;
  39. case 2:
  40. printf("Podaj promien podstawy: ");
  41. scanf("%d",&r);
  42. printf("Podaj wysokosc walca: ");
  43. scanf("%d",&a);
  44. walec(a,r);break;
  45. case 3:
  46. printf("Podaj x: ");
  47. scanf("%f",&x);
  48. printf("Podaj y: ");
  49. scanf("%f",&y);
  50. punkt(x,y);break;
  51. case 4:
  52. wyplata();break;
  53. case 5:
  54. printf("Podaj znak dzialania\n");
  55. fflush(stdin);
  56. scanf("%c",&znak);
  57. printf("Podaj 1 liczbe\n");
  58. scanf("%f",&x);
  59. printf("Podaj 2 liczbe\n");
  60. scanf("%f",&y);
  61. printf("wynik twojego dzialania wynosi %0.2f", kalkulator(znak, x, y));break;
  62. case 6:
  63. printf("Podaj litere: ");
  64. fflush(stdin);
  65. scanf("%c",&litera);
  66. czySamo(litera);break;
  67. case 7:
  68. printf("Podaj ilosc liczb: ");
  69. scanf("%d",&n);
  70. suma(n);break;
  71. case 8:
  72. szlaczek();break;
  73. case 9:
  74. ileDodatnich();break;
  75. default:
  76. printf("Zly wybor\n");
  77. }
  78. return 0;
  79. }
  80. int szescian(int a)
  81. {
  82. int pole;
  83. pole=a*a*a;
  84. printf("Pole wynosi %d",pole);
  85. }
  86. int walec(int a, int r)
  87. {
  88. int obj;
  89. obj=3.14*r*r*a;
  90. printf("Obj walca wynosi %d",obj);
  91. }
  92. void punkt(float x, float y)
  93. {
  94. if((x>=-1) && (x<=1) && (y>=-1) && (y<=1))
  95. printf("Punkty naleza do zamalowanego obszaru");
  96. else
  97. printf("Blad");
  98. }
  99. void wyplata()
  100. {
  101. int p, s;
  102. float pensja;
  103. printf("Podaj pensje: ");
  104. scanf("%d",&p);
  105. printf("Podaj lata stazu: ");
  106. scanf("%d",&s);
  107. if (s<5)
  108. {
  109. printf("Dodatek sie nie nalezy, pensja wynosi %d",p);
  110. }
  111. else if ((s>=5) && (s<=10))
  112. {
  113. printf("Dodatek wynosi %d procent\n",s);
  114. pensja=s/100.*p+p;
  115. printf("Pensja wynosi %0.2f",pensja);
  116. }
  117. else if (s>10)
  118. {
  119. printf("Dodatek wynosi 15%\n");
  120. pensja=1.15*p;
  121. printf("Pensja wynosi %0.2f",pensja);
  122. }
  123. }
  124. float kalkulator(char znak, float x, float y)
  125. {
  126. switch(znak)
  127. {
  128. case '-':
  129. return x-y;break;
  130. case '+':
  131. return x+y;break;
  132. default:
  133. printf("Bledny znak\n");break;
  134. }
  135. }
  136. void czySamo(char litera)
  137. {
  138. switch(litera)
  139. {
  140. case 'a':
  141. case 'A':
  142. case 'e':
  143. case 'E':
  144. case 'i':
  145. case 'I':
  146. case 'o':
  147. case 'O':
  148. case 'u':
  149. case 'U':
  150. case 'y':
  151. case 'Y':
  152. printf("Samogloska\n");break;
  153. default:
  154. printf("Wspolgloska\n");break;
  155. }
  156. }
  157. void suma(int n)
  158. {
  159. int i=1;
  160. int suma=0;
  161. int a;
  162.  
  163. while(i<=n)
  164. {
  165. printf("Podaj liczbe: ");
  166. scanf("%d",&a);
  167. printf("\n");
  168. suma=suma+a;
  169. printf("Suma wynosi: %d\n",suma);
  170. i++;
  171. }
  172. printf("Suma wynosi: %d", suma);
  173. }
  174. void szlaczek()
  175. {
  176. int g;
  177. int i; //ilosc gwiazdek w szlaczku
  178. int wiersz; //ilosc wierszy szlaczku
  179. printf("Podaj ilosc gwiazdek w szlaczku: ");
  180. scanf("%d",&i);
  181. printf("Podaj ilosc wierszy szlaczku: ");
  182. scanf("%d",&wiersz);
  183. while (wiersz>=1)
  184. {
  185.  
  186. for (g=1; g<=i; g++)
  187. printf("*");
  188. wiersz--;
  189. printf("\n");
  190. }
  191.  
  192. }
  193. void ileDodatnich()
  194. {
  195. int x=1;
  196. int i=0;
  197. printf("Podaj ciag liczb zakonczonych zerem\n");
  198. while(x=!0)
  199. {
  200. if(x>0)
  201. {
  202. i++;
  203. printf("Podaj kolejna liczbe ");
  204. scanf("%d",&x);
  205. printf("%d",i);
  206. } else if (x<0)
  207. {
  208. printf("Podaj kolejna liczbe ");
  209. scanf("%d",&x);
  210. printf("%d",i);
  211. } else
  212. printf("Jest %d liczb dodatnich",i);
  213. }
  214.  
  215. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement