Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 6.1
- #include <iostream>
- using namespace std;
- unsigned long long int f(int n)
- {
- if(n == 0) return 0;
- if(n == 1 || n == 2) return 1;
- return f(n-1)+f(n-2);
- }
- int main()
- {
- int j;
- cout<< " введите число "<<endl;
- cin >> j;
- cout <<"F("<<j<<")= "<< f(j) << endl;
- return 0;
- }
- 6.2
- #include<iostream>
- #include<cmath>
- #include<iomanip>
- using namespace std;
- unsigned long long int f(int n)
- {
- if(n == 0) return 0;
- if(n == 1 || n == 2) return 1;
- return f(n-1)+f(n-2);
- }
- int main()
- {
- double a,c,d,e,fi,g,k;
- cout<<setprecision(11);
- cout<< " Введите с какой точностью"<<endl;
- cout<< "Esp=";
- cin>>e;
- fi=((sqrt(5)+1)/2);
- cout<<"fi="<<fi<<endl;
- k=20000;
- int n=2;
- while(n<k){
- d=f(n);
- a=f(n-1);
- c=d/a;
- g=abs(c-fi);
- if (g<e){
- cout<<"f("<<n<<")="<<c<<endl;
- return 0;}
- n++;
- }
- return 0;
- }
- 7.1
- #include <iostream>
- #include <ctime>
- #include <algorithm>
- using namespace std;
- void rand(int * marry, int c){
- srand(time(NULL));
- for(int x=0; x<c; x++){
- marry[x]=rand()%7;
- }
- }
- void end(int * marry, int c){
- for(int x=0; x<c; x++){
- cout<<marry[x]<<" ";
- }
- }
- int can(int * marry, int c){
- int mini = marry[0];
- for(int x=0; x<c; x++){
- if(marry[x]<=mini){
- mini=marry[x];
- }
- }
- return mini;
- }
- int main()
- {
- int c;
- cin>>c;
- int marry[c];
- rand(marry,c);
- end(marry,c);
- int minimal_value = can(marry, c);
- cout <<" "<< "Minimal value : " << minimal_value <<endl;
- return 0;
- }
- 7.2
- #include <iostream>
- #include <ctime>
- #include <algorithm>
- using namespace std;
- void rand(int * marry, int c){
- srand(time(NULL));
- for(int x=0; x<c; x++){
- marry[x]=rand()%7;
- }
- }
- void end(int * marry, int c){
- for(int x=0; x<c; x++){
- cout<<marry[x]<<" ";
- }
- }
- int can(int * marry, int c){
- int mini = marry[0];
- for(int x=0; x<c; x++){
- if(marry[x]<=mini){
- mini=marry[x];
- }
- }
- return mini;
- }
- int main()
- {
- int c;
- cin>>c;
- int marry[c];
- rand(marry,c);
- end(marry,c);
- int minimal_value = can(marry, c);
- cout <<" "<< "Minimal value : " << minimal_value <<endl;
- return 0;
- }
- другой вариант 7.2
- #include <iostream>
- #include <ctime>
- #include <algorithm>
- using namespace std;
- void rand(int * marry, int c){
- srand(time(NULL));
- for(int x=0; x<c; x++){
- marry[x]=rand()%7;
- }
- }
- void end(int * marry, int c){
- for(int x=0; x<c; x++){
- cout<<marry[x]<<" ";
- }
- }
- int can(int * marry, int c){
- int mini = marry[0];
- for(int x=0; x<c; x++){
- if(marry[x]<=mini){
- mini=marry[x];
- }
- }
- return mini;
- }
- int get_minimum_2(int a, int b) {
- if (a < b) return a;
- return b;
- }
- int get_minimum_3(int a, int b, int c) {
- return get_minimum_2(a, get_minimum_2(b, c));
- }
- int get_minimum_6(int a, int b, int c, int d, int e, int f) {
- return get_minimum_2(get_minimum_3(a, b, c), get_minimum_3(d, e, f));
- }
- 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) {
- return get_minimum_2(get_minimum_6(a, b, c,k,l,j), get_minimum_6(d, e, f,s,q,y));
- }
- int main()
- {
- int c;
- cin>>c;
- int marry[c];
- rand(marry,c);
- end(marry,c);
- int minimal_value = can(marry, c);
- cout <<" "<< "Minimal value : " << minimal_value <<endl;
- cout << get_minimum_2(1, 4) << endl;
- cout << get_minimum_6(10, 4, 12,-149, 3, 0) <<endl;
- cout << get_minimum_12(10, 4, 12,-149, 3, 0,6,8,-2438,1020,924,-512) <<endl;
- return 0;
- }
- 7.3
- #include <iostream>
- #include <cmath>
- int main()
- {
- using namespace std;
- int m;
- bool JM=true;
- int l=1;
- for(int u=10;u>l;u++){
- cout << "Введите N: ";
- cin >> m;
- for (int x=2;x<=sqrt(m);x++)
- {
- if (m%x==0)
- JM=false;
- }
- if (JM==true)
- cout << "Простое."<<endl;
- else
- cout << "Не простое ."<<endl;
- JM=true;
- }
- return 0;
- }
- 7.4
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int ox,oy,x,y,r,x1,y1,m;
- cout<< "Введите координату х центра:";
- cin>>ox;
- cout<< "Введите координату у центра:";
- cin>>oy;
- cout<< "Введите координату х Точки:";
- cin>>x;
- cout<< "Введите координату у Точки:";
- cin>>y;
- cout<< "Введите длину радиуса:";
- cin>>r;
- x1=x-ox;
- y1=y-oy;
- m=((x1)*(x1)+(y1)*(y1));
- if (m==r*r)
- {
- cout<<"0"<<endl;
- }
- if(m>r*r)
- {
- cout<<"-1"<<endl;
- }
- if (m<r*r)
- {
- cout<<"1"<<endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment