Advertisement
TwiNNeR

cpp mendo zadachi

Feb 16th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.97 KB | None | 0 0
  1. //19. Tochka
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int px, py;
  9.     cin >> px >> py;
  10.      
  11.     int a, b;
  12.     cin >> a >> b;
  13.      
  14.     int x, y;
  15.     cin >> x >> y;
  16.      
  17.     if ((x>=px && x<=px+a) && (y>=py && y<=py+b))      
  18.     {
  19.                if (x==px||x==px+a||y==py||y==py+b)              
  20.                   cout << "strana" << endl;
  21.                else
  22.                    cout << "vnatre" << endl;                  
  23.     } else
  24.     {
  25.           cout << "nadvor" << endl;    
  26.     }
  27.      
  28.     return 0;
  29. }
  30.  
  31. //////////////////////////////////////////////////////////
  32.  
  33. //21. Faktoriel
  34.  
  35. #include <iostream>
  36.  
  37. using namespace std;
  38.  
  39. int main()
  40. {
  41.     int i,a,f;
  42.     cin>>a;
  43.  for (i = 0; i <= a; i++)
  44.  
  45.         if (i == 0)
  46.         {f = 1;}
  47.         else {
  48.         f = f * i;}
  49.     cout<<f;
  50.  
  51.     return 0;
  52. }
  53.  
  54. //22. Збир до N
  55.  
  56. #include <iostream>
  57.  
  58. using namespace std;
  59.  
  60.  
  61. int main()
  62.  
  63. {
  64. int i,n,z=0;
  65.  
  66.  
  67. cin>>n;
  68.  
  69.  
  70. for(i=1;i<=n;i++)
  71. {
  72.  
  73. z= z + i;
  74.  
  75. }
  76. cout<<z;
  77.  
  78. return 0;
  79. }
  80.  
  81. //////////////////////////////////////////////////////////
  82.  
  83. //23. broj na cifri
  84.  
  85. #include <iostream>
  86.  
  87. using namespace std;
  88.  
  89. int main()
  90. {
  91.     int a;
  92.     cin>>a;
  93.     if(a >= 10000 & a <=30000)
  94.     {
  95.         cout<<5<<endl;
  96.  
  97.     }
  98.     if(a>=1000 & a<10000)
  99.     {
  100.         cout<<4<<endl;
  101.     }
  102.     if(a>=100 & a<1000)
  103.     {
  104.         cout<<3<<endl;
  105.  
  106.     }
  107.     if(a>=10 & a<100)
  108.     {
  109.         cout<<2<<endl;
  110.     }
  111.     if(a>=0 & a<10)
  112.     {
  113.         cout<<1<<endl;
  114.     }
  115.  
  116.  
  117.     return 0;
  118. }
  119.  
  120. //////////////////////////////////////////////////////////
  121.  
  122. //24. sodrzhatel
  123.  
  124. #include <stdio.h>
  125. #include <tchar.h>
  126. #include <iostream>
  127.  
  128.  
  129. using namespace std;
  130. int _tmain(int argc, _TCHAR* argv[])
  131. {
  132.     int m,n,p,z;
  133.     cin>>m;
  134.     cin>>n;
  135.     p=0;
  136.     int i=2;
  137.     if(m>=1 && n<=500)
  138.     {
  139.          
  140.  
  141.         while(i<=500 && p==0)
  142.         {
  143.             if(i%m==0 && i%n==0)
  144.             {
  145.                 p++;
  146.             }
  147.             else i++;
  148.         }
  149.         cout<<i;
  150.     }
  151.     else cout<<"ne vnesovte pravilno";
  152.      
  153. }
  154.  
  155. //////////////////////////////////////////////////////////
  156.  
  157. //25. faktorizacija
  158.  
  159. #include <iostream>
  160. using namespace std;
  161.  
  162. int main()
  163. {
  164.     int n, base=2, deg, first=1;
  165.     cin >> n;
  166.      
  167.     while (n >= 2)
  168.     {
  169.           deg = 0;
  170.            
  171.           while (n%base == 0)
  172.           {
  173.                 n /= base;
  174.                 deg = deg+1;
  175.           }
  176.                  
  177.           if (deg > 0)
  178.           {
  179.                   if (first == 1)
  180.                   {
  181.                      cout << "(" << base << "^" << deg << ")";
  182.                      first = 0;
  183.                   } else
  184.                   {
  185.                      cout << "*" << "(" << base << "^" << deg << ")";
  186.                   }                  
  187.           }
  188.            
  189.           base = base + 1;                    
  190.     }
  191.      
  192.     cout << endl;
  193.     return 0;
  194. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement