FilipKinderman

Zadania

Feb 8th, 2021 (edited)
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.26 KB | None | 0 0
  1. Zadanie 1.
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int SUMA (int a, int b)
  7. {
  8. return a+b;
  9.  
  10. }
  11. int main ()
  12.  
  13. cout<<SUMA(4,5);
  14. if(SUMA(2,3)<15)
  15. cout<<"Suma jest mniejsza niz 15";
  16.  
  17. return 0;
  18. }
  19.  
  20. Zadanie 2.
  21.  
  22. #include <iostream>
  23. using namespace std;
  24.  
  25. int WARTOSC_BEZWZGLEDNA (int a);
  26. (
  27.  if (x<0)
  28.     x=x*-1;
  29.     return x;
  30.  
  31.  
  32.  int main(){
  33.  
  34.  cout<<WARTOSC_BEZWZGLEDNA
  35.  return 0;
  36.  
  37.  
  38.  )
  39.  }
  40.  
  41. Zadanie 3.
  42.  
  43. #include <iostream>
  44. using namespace std;
  45.  
  46. bool CZY_PARZYSTA(int a);
  47. (
  48.     if(x%2=0)
  49.     (
  50.      return true;
  51.  
  52.      )
  53.      else (return false);
  54.  
  55.  )
  56.  
  57.  int main(){
  58.  
  59.  
  60.  cout<<CZYP_PARZYSTA(8);
  61.  return 0;
  62.  }
  63.  
  64.  
  65. Zadanie 4.
  66.  
  67. #include <iostream>
  68. using namespace std;
  69.  
  70. void SZLACZEK(int lc,char a)
  71. (
  72.     for(int i=0;i<lc;i=i+i)
  73.     {
  74.         cout<<a;
  75.     }
  76.  
  77.  )
  78.  int main(){
  79.  
  80.  
  81.     SZLACZEK(10,'*');
  82.     return 0
  83.  
  84.  }
  85.  
  86.  
  87. Zadanie 5.
  88.  
  89. #include <iostream>
  90. using namespace std;
  91.  
  92. int potega (int x, int y)
  93. {
  94.     int a=1;
  95.     if (x>0)
  96. {
  97.     for (int i=0; i<y;i=i+1)
  98.     {
  99.     a=x*a;
  100.     }
  101. }
  102. return a;
  103. }
  104. int main ()
  105. {
  106. cout<<potega(4,5);
  107. return 0;
  108. }
  109.  
  110. Zadanie 6.
  111.  
  112. #include <iostream>
  113. using namespace std;
  114.  
  115. int OBWOD_TROJKATA (int a, int b, int c)
  116.  { int o;
  117. if (a>0&&b>0&&c>0&&a+b>c&&b+c>a&&c+b>a)
  118. {
  119. o=a+b+c;
  120. return o;
  121. }
  122. else return -1;
  123. }
  124. int main ()
  125. {
  126. cout<<OBWOD_TROJKATA(3,4,5)<<endl;
  127. if (OBWOD_TROJKATA(3,4,-1)==-1 cout<<"Z podanych bokow nie mozna utworzyc trojkata";
  128. return 0;
  129.  
  130. Zadanie 7.
  131.  
  132. #include <iostream>
  133. using namespace std;
  134.  
  135. int silnia(int x)
  136. {
  137. int i=1;
  138. int y=1;
  139.     while (i<-x)
  140.     {
  141.     y=y+1;
  142.     i++;
  143. }
  144. return y;
  145. }
  146. int main ()
  147. {
  148. cout<<silnia(4);
  149.  
  150. return 0;
  151. }
  152.  
  153. Zadanie 8.
  154. #include <iostream>
  155. using namespace std;
  156.  
  157. int MAX(int a,int b,int c){
  158.  
  159.     if(a>b&&a>c){
  160.         return a;
  161.     }
  162.     if(b>a&&b>z){
  163.         return b;
  164.     }
  165.     if(c>b&&c>a)
  166.     return c;
  167. }
  168.  
  169. int main() {
  170.  
  171.     int a,b,c;
  172.     cout << "Wprowadz trzy liczby calkowite " <<endl;
  173.     cin >> a;
  174.     cin >> b;
  175.     cin >> c;
  176.     cout << MAX(a,b,c);
  177.  
  178.    return 0;
  179.  
  180. Zadanie 9.
  181.  
  182. #include <iostream>
  183. using namespace std;
  184.  
  185. void DZIELNIKI(int n){
  186.  
  187.     for(int i = 1; i <= n; i++)
  188. {
  189.         if(n % i ==0)
  190.  
  191. {
  192.             cout << i << endl;
  193.         }
  194.     }
  195. }
  196. int main() {
  197.     DZIELNIKI(210);
  198.     return 0;
  199. }
  200.  
Add Comment
Please, Sign In to add comment