Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. Zadanie 1.1
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. void Ball(double r,double *S,double *V){
  8. double pi=3.14;
  9. *S=4*pi*r*r;
  10. *V=pi*r*r*r/3;
  11. }
  12.  
  13. int main()
  14. {
  15. double r,S,V;
  16. for(int i=0;i<3;i++){
  17. cout<<"Podaj r: ";
  18. cin>>r;
  19. Ball(r,&S,&V);
  20. cout<<S<<" , "<<V<<endl;
  21.  
  22. }
  23.  
  24. return 0;
  25. }
  26.  
  27.  
  28. Zadanie 1.2
  29.  
  30. #include <iostream>
  31.  
  32. using namespace std;
  33.  
  34. void Cube(double a,double *S,double *V){
  35. double pi=3.14;
  36. *S=6*a*a;
  37. *V=a*a*a;
  38. }
  39.  
  40. int main()
  41. {
  42. double a,S,V;
  43. for(int i=0;i<4;i++){
  44. cout<<"Podaj a: ";
  45. cin>>a;
  46. Cube(a,&S,&V);
  47. cout<<S<<" , "<<V<<endl;
  48.  
  49. }
  50.  
  51. return 0;
  52. }
  53.  
  54.  
  55. Zadanie 1.3
  56.  
  57. #include <iostream>
  58. #include <math.h>
  59.  
  60. using namespace std;
  61.  
  62. void Cone(double r,double h,double *S,double *V){
  63. double pi=3.14;
  64. *S=pi*r*(r+sqrt(r*r+h*h));
  65. *V=pi*r*r*h/3;
  66. }
  67.  
  68. int main()
  69. {
  70. double r,h,S,V;
  71. for(int i=0;i<2;i++){
  72. cin>>r>>h;
  73. Cone(r,h,&S,&V);
  74. cout<<S<<" , "<<V<<endl;
  75. }
  76.  
  77. return 0;
  78. }
  79.  
  80.  
  81.  
  82. Zadanie 1.4
  83.  
  84. #include <iostream>
  85. #include <math.h>
  86.  
  87. using namespace std;
  88.  
  89. void Cylinder(double r,double h,double *S,double *V){
  90. double pi=3.14;
  91. *S=2*pi*r*(r+h);
  92. *V=pi*r*r*h;
  93. }
  94.  
  95. int main()
  96. {
  97. double r,h,S,V;
  98. for(int i=0;i<5;i++){
  99. cin>>r>>h;
  100. Cylinder(r,h,&S,&V);
  101. cout<<S<<" , "<<V<<endl;
  102.  
  103. }
  104.  
  105. return 0;
  106. }
  107.  
  108.  
  109. Zadanie 2.1
  110.  
  111. #include <iostream>
  112. #include <math.h>
  113.  
  114. using namespace std;
  115.  
  116. double fun1(double x){
  117. double rez;
  118. rez=cos(x)+sin(x);
  119. return rez;
  120. }
  121.  
  122. int main()
  123. {
  124.  
  125. double x,rez;
  126. for(int i=0;i<5;i++){
  127. cin>>x;
  128. rez=fun1(x);
  129. cout<<rez<<endl;
  130. }
  131. return 0;
  132. }
  133.  
  134.  
  135. Zadanie 2.2
  136.  
  137. #include <iostream>
  138. #include <math.h>
  139.  
  140. using namespace std;
  141.  
  142. double fun2(double x){
  143. double rez;
  144. rez=(exp(x)-exp(-1))/2;
  145. return rez;
  146. }
  147.  
  148. int main()
  149. {
  150.  
  151. double x,rez;
  152. for(int i=0;i<3;i++){
  153. cin>>x;
  154. rez=fun2(x);
  155. cout<<rez<<endl;
  156. }
  157. return 0;
  158. }
  159.  
  160. Zadanie 2.3
  161.  
  162. #include <iostream>
  163. #include <math.h>
  164.  
  165. using namespace std;
  166.  
  167. double fun3(double x){
  168. double rez;
  169. rez=2*(cos(x)*cos(x)-1);
  170. return rez;
  171. }
  172.  
  173. int main()
  174. {
  175.  
  176. double x,rez;
  177. for(int i=0;i<4;i++){
  178. cin>>x;
  179. rez=fun3(x);
  180. cout<<rez<<endl;
  181. }
  182. return 0;
  183. }
  184.  
  185. Zadanie 2.4
  186.  
  187. #include <iostream>
  188. #include <math.h>
  189.  
  190. using namespace std;
  191.  
  192. double fun4(double x){
  193. double rez;
  194. rez=(1+2*x*x)*exp(x*x);
  195. return rez;
  196. }
  197.  
  198. int main()
  199. {
  200.  
  201. double x,rez;
  202. for(int i=0;i<2;i++){
  203. cin>>x;
  204. rez=fun4(x);
  205. cout<<rez<<endl;
  206. }
  207. return 0;
  208. }
  209.  
  210. Zadanie 3
  211.  
  212. #include <iostream>
  213.  
  214. using namespace std;
  215.  
  216. int main()
  217. {
  218. int n;
  219. double h,a=2.2,sum=a;
  220. cin>>n;
  221. h=2.4-2.2;
  222. for(int i=2;i<=n;i++){
  223. a+=h;
  224. sum+=a;
  225. }
  226. cout<<a<<" , "<<sum;
  227.  
  228. return 0;
  229. }
  230.  
  231.  
  232. Zadanie 4
  233.  
  234. #include <iostream>
  235.  
  236. using namespace std;
  237.  
  238. int main()
  239. {
  240. int n,a,m=0;
  241. cin>>n;
  242. for(int i=1;i<=n;i++){
  243. cin>>a;
  244. if(a>0 && a%2==0){
  245. m++;
  246. }
  247. }
  248. cout<<m;
  249.  
  250. return 0;
  251. }
  252.  
  253. Zadanie 5
  254.  
  255. #include <iostream>
  256.  
  257. using namespace std;
  258.  
  259. int main()
  260. {
  261. int a,max = -1000;
  262. do{
  263. cin>>a;
  264. if(a<0 && a>max){
  265. max=a;
  266. }
  267. }while(a!=0);
  268. cout<<max;
  269.  
  270. return 0;
  271. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement