Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="">
  3.  
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title></title>
  8. </head>
  9.  
  10. <body>
  11. <H1>zadanie 1</H1>
  12.  
  13. <?php
  14. $poczatek=1;
  15. $koniec=11;
  16. $suma = 0;
  17.  
  18. for($i=$poczatek;$i<$koniec;$i++)
  19. {
  20. $a = $suma+=$i;
  21.  
  22. }
  23. echo $a,' ' ;
  24.  
  25.  
  26. $suma =0;
  27. $i=0;
  28. do{
  29.  
  30. $b = $suma+=$i;
  31. $i++;
  32.  
  33. }while($i<=10);
  34. echo $b,' ';
  35.  
  36. $suma =0;
  37. $i=0;
  38. while($i<=10){
  39. $c = $suma+=$i;
  40. $i++;
  41. }
  42. echo $c,' ';
  43.  
  44. ?>
  45. <h1>Zadanie 2</h1>
  46. <form method="post">
  47. <input type="number" name="liczba1">
  48. <input type="text" name="znak">
  49. <input type="number" name="liczba2">
  50. <input type="submit" name="policz">
  51.  
  52.  
  53. </form>
  54. <?php
  55. if($_POST['znak']=='+'){
  56. $suma = $_POST['liczba1'] + $_POST['liczba2'];
  57. echo $suma;
  58. }
  59. else if($_POST['znak']=='-'){
  60. $różnica = $_POST['liczba1'] - $_POST['liczba2'];
  61. echo $różnica;
  62.  
  63. }else if($_POST['znak']=='*'){
  64. $iloczyn = $_POST['liczba1'] * $_POST['liczba2'];
  65. echo $iloczyn;
  66.  
  67. }else if($_POST['znak']==':' or $_POST['znak']=='/' ){
  68. $iloraz = $_POST['liczba1'] / $_POST['liczba2'];
  69. echo $iloraz;
  70.  
  71. }
  72. else{
  73. echo 'podaj poprawny znak';
  74. }
  75. ?>
  76. <h1>zadanie 3</h1>
  77. <form method="post">
  78. podaj 3 liczby
  79. <input type="number" name="z">
  80. <input type="number" name="x">
  81. <input type="number" name="v">
  82. <input type="submit" name="spr">
  83. <?php
  84. if($_POST['z']>=$_POST['x'] and $_POST['z']>=$_POST['v']){
  85. echo 'liczba ',$_POST['z'],' jest największa ';
  86. }
  87. else if($_POST['x']>=$_POST['z'] and $_POST['x']>=$_POST['v']){
  88. echo 'liczba ',$_POST['x'],' jest największa ';
  89. }
  90. else {
  91. echo 'liczba ',$_POST['v'],' jest największa ';
  92. }
  93.  
  94. ?>
  95. <h1>zadanie 4</h1>
  96. <form method="post">
  97. <input type="number" name="a">
  98. <input type="number" name="b">
  99. <input type="submit">
  100. </form>
  101. <?php
  102. if($_POST['a']>=10 and $_POST['b']>=10){
  103. $roz = $_POST['a']/$_POST['b'];
  104. echo $roz;
  105. }
  106. else if($_POST['a']>=10 and $_POST['b']<=10){
  107. $roz = $_POST['a']-$_POST['b'];
  108. echo $roz;
  109. }
  110. else if($_POST['a']<=10 or $_POST['b']<=10){
  111. $ilo = $_POST['a']*$_POST['b'];
  112. echo $ilo;
  113. }
  114. else {
  115. $sum = $_POST['a']+$_POST['b'];
  116. echo $sum;
  117. }
  118. ?>
  119. <h1>zadanie 5</h1>
  120. <form method="post">
  121. podaj przedział
  122. od <input type="number" name="liczb_a">
  123. do<input type="number" name="liczb_b">
  124. do<input type="submit">
  125. </form>
  126. <?php
  127.  
  128. $a= $_POST['liczb_a'];
  129. $b= $_POST['liczb_b'];
  130. $tab[] =0;
  131. $i=0;
  132. if($a %2==0){
  133.  
  134.  
  135. while($a<$b){
  136.  
  137. $tab[$i]=$a;
  138. $i++;
  139. $a=$a+2;
  140. }if($b%2==0){
  141. $tab[$i+1]=$b;
  142. }
  143. }
  144. else {
  145. $a=$a+1;
  146. while($a<$b){
  147.  
  148. $tab[$i]=$a;
  149. $i++;
  150. $a=$a+2;
  151. }if($b%2==0){
  152. $tab[$i+1]=$b;
  153. }
  154.  
  155. }
  156. $policzone=0;
  157. for($o=0;$o<$i or $o==$i ;$o++){
  158. $policzone= $policzone+$tab[$o];
  159. }
  160. print_r($tab);
  161. echo $policzone;
  162.  
  163. ?>
  164.  
  165.  
  166. </form>
  167. </body>
  168.  
  169. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement