ElenaMednikova

Untitled

Dec 11th, 2019
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.42 KB | None | 0 0
  1. 6.1
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. unsigned long long int f(int n)
  7. {
  8. if(n == 0) return 0;
  9. if(n == 1 || n == 2) return 1;
  10.  
  11. return f(n-1)+f(n-2);
  12. }
  13.  
  14. int main()
  15. {
  16. int j;
  17. cout<< " введите число "<<endl;
  18. cin >> j;
  19. cout <<"F("<<j<<")= "<< f(j) << endl;
  20. return 0;
  21. }
  22. 6.2
  23. #include<iostream>
  24. #include<cmath>
  25. #include<iomanip>
  26.  
  27. using namespace std;
  28.  
  29. unsigned long long int f(int n)
  30. {
  31. if(n == 0) return 0;
  32. if(n == 1 || n == 2) return 1;
  33.  
  34. return f(n-1)+f(n-2);
  35. }
  36.  
  37. int main()
  38. {
  39. double a,c,d,e,fi,g,k;
  40. cout<<setprecision(11);
  41. cout<< " Введите с какой точностью"<<endl;
  42. cout<< "Esp=";
  43. cin>>e;
  44. fi=((sqrt(5)+1)/2);
  45. cout<<"fi="<<fi<<endl;
  46. k=20000;
  47. int n=2;
  48. while(n<k){
  49. d=f(n);
  50. a=f(n-1);
  51. c=d/a;
  52. g=abs(c-fi);
  53. if (g<e){
  54. cout<<"f("<<n<<")="<<c<<endl;
  55. return 0;}
  56. n++;
  57. }
  58. return 0;
  59. }
  60. 7.1
  61. #include <iostream>
  62. #include <ctime>
  63. #include <algorithm>
  64. using namespace std;
  65. void rand(int * marry, int c){
  66. srand(time(NULL));
  67. for(int x=0; x<c; x++){
  68. marry[x]=rand()%7;
  69. }
  70. }
  71. void end(int * marry, int c){
  72. for(int x=0; x<c; x++){
  73. cout<<marry[x]<<" ";
  74. }
  75. }
  76. int can(int * marry, int c){
  77. int mini = marry[0];
  78. for(int x=0; x<c; x++){
  79. if(marry[x]<=mini){
  80. mini=marry[x];
  81. }
  82. }
  83. return mini;
  84. }
  85. int main()
  86. {
  87. int c;
  88. cin>>c;
  89. int marry[c];
  90. rand(marry,c);
  91. end(marry,c);
  92. int minimal_value = can(marry, c);
  93. cout <<" "<< "Minimal value : " << minimal_value <<endl;
  94. return 0;
  95. }
  96. 7.2
  97. #include <iostream>
  98. #include <ctime>
  99. #include <algorithm>
  100. using namespace std;
  101. void rand(int * marry, int c){
  102. srand(time(NULL));
  103. for(int x=0; x<c; x++){
  104. marry[x]=rand()%7;
  105. }
  106. }
  107. void end(int * marry, int c){
  108. for(int x=0; x<c; x++){
  109. cout<<marry[x]<<" ";
  110. }
  111. }
  112. int can(int * marry, int c){
  113. int mini = marry[0];
  114. for(int x=0; x<c; x++){
  115. if(marry[x]<=mini){
  116. mini=marry[x];
  117. }
  118. }
  119. return mini;
  120. }
  121. int main()
  122. {
  123. int c;
  124. cin>>c;
  125. int marry[c];
  126. rand(marry,c);
  127. end(marry,c);
  128. int minimal_value = can(marry, c);
  129. cout <<" "<< "Minimal value : " << minimal_value <<endl;
  130. return 0;
  131. }
  132. другой вариант 7.2
  133. #include <iostream>
  134. #include <ctime>
  135. #include <algorithm>
  136. using namespace std;
  137. void rand(int * marry, int c){
  138. srand(time(NULL));
  139. for(int x=0; x<c; x++){
  140. marry[x]=rand()%7;
  141. }
  142. }
  143. void end(int * marry, int c){
  144. for(int x=0; x<c; x++){
  145. cout<<marry[x]<<" ";
  146. }
  147. }
  148. int can(int * marry, int c){
  149. int mini = marry[0];
  150. for(int x=0; x<c; x++){
  151. if(marry[x]<=mini){
  152. mini=marry[x];
  153. }
  154. }
  155. return mini;
  156. }
  157.  
  158. int get_minimum_2(int a, int b) {
  159. if (a < b) return a;
  160. return b;
  161. }
  162.  
  163. int get_minimum_3(int a, int b, int c) {
  164. return get_minimum_2(a, get_minimum_2(b, c));
  165. }
  166.  
  167. int get_minimum_6(int a, int b, int c, int d, int e, int f) {
  168. return get_minimum_2(get_minimum_3(a, b, c), get_minimum_3(d, e, f));
  169. }
  170. int get_minimum_12(int a, int b, int c, int d, int e, int f,int j,int k,int l,int s,int q,int y) {
  171. return get_minimum_2(get_minimum_6(a, b, c,k,l,j), get_minimum_6(d, e, f,s,q,y));
  172. }
  173.  
  174. int main()
  175. {
  176. int c;
  177. cin>>c;
  178. int marry[c];
  179. rand(marry,c);
  180. end(marry,c);
  181. int minimal_value = can(marry, c);
  182. cout <<" "<< "Minimal value : " << minimal_value <<endl;
  183. cout << get_minimum_2(1, 4) << endl;
  184. cout << get_minimum_6(10, 4, 12,-149, 3, 0) <<endl;
  185. cout << get_minimum_12(10, 4, 12,-149, 3, 0,6,8,-2438,1020,924,-512) <<endl;
  186.  
  187. return 0;
  188. }
  189. 7.3
  190. #include <iostream>
  191. #include <cmath>
  192.  
  193. int main()
  194. {
  195. using namespace std;
  196. int m;
  197. bool JM=true;
  198. int l=1;
  199. for(int u=10;u>l;u++){
  200. cout << "Введите N: ";
  201. cin >> m;
  202.  
  203. for (int x=2;x<=sqrt(m);x++)
  204. {
  205. if (m%x==0)
  206. JM=false;
  207. }
  208. if (JM==true)
  209. cout << "Простое."<<endl;
  210. else
  211. cout << "Не простое ."<<endl;
  212. JM=true;
  213. }
  214. return 0;
  215. }
  216. 7.4
  217. #include <iostream>
  218. #include <cmath>
  219. using namespace std;
  220.  
  221. int main()
  222. {
  223. int ox,oy,x,y,r,x1,y1,m;
  224. cout<< "Введите координату х центра:";
  225. cin>>ox;
  226. cout<< "Введите координату у центра:";
  227. cin>>oy;
  228. cout<< "Введите координату х Точки:";
  229. cin>>x;
  230. cout<< "Введите координату у Точки:";
  231. cin>>y;
  232. cout<< "Введите длину радиуса:";
  233. cin>>r;
  234. x1=x-ox;
  235. y1=y-oy;
  236. m=((x1)*(x1)+(y1)*(y1));
  237. if (m==r*r)
  238. {
  239. cout<<"0"<<endl;
  240. }
  241. if(m>r*r)
  242. {
  243. cout<<"-1"<<endl;
  244. }
  245. if (m<r*r)
  246. {
  247. cout<<"1"<<endl;
  248. }
  249. return 0;
  250. }
Add Comment
Please, Sign In to add comment