Advertisement
Technoblade777

ДЗ 27.09.22

Sep 27th, 2022
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.09 KB | None | 0 0
  1. /*
  2. 1
  3. int main(){
  4.     int sum, n, x, xt, k = 0;
  5.     cout << "Amount of numbers: ";
  6.     cin >> n;
  7.     for(int i = 1; i<=n; i++)
  8.     {
  9.         cin >> x;
  10.         xt = x;
  11.         while(xt != 0)
  12.         {
  13.             if(xt%10 == 7){sum += x;}
  14.             xt = xt / 10;
  15.             k++;
  16.         }
  17.         k = 0;
  18.     }
  19.     cout << "Res: " << sum;
  20. }
  21. 2
  22. int main(){
  23.     int sum, n, x, xt, k = 0;
  24.     cout << "Amount of numbers: ";
  25.     cin >> n;
  26.     for(int i = 1; i <= n; i++)
  27.     {
  28.         cin >> x;
  29.         xt = x;
  30.         while(xt > 0)
  31.         {
  32.             sum += xt%10;
  33.             xt /= 10;
  34.         }
  35.         if(sum%2==0){k++;}
  36.     }
  37.     cout << "Res: " << k;
  38. }
  39. 3
  40. int main(){
  41.     int n, x, xt, check = 0, c=1, k = 0;
  42.     cout << "Amount of numbers: ";
  43.     cin >> n;
  44.     for(int i = 1; i <= n; i++)
  45.     {
  46.         cin >> x;
  47.         while(c != x)
  48.         {
  49.             if(x%c==0){check++;}
  50.             c++;
  51.         }
  52.         c = 2;
  53.         if(check == 0){k++;}
  54.         check = 0;
  55.     }
  56.     cout << "Res: " << k;
  57. }
  58. 4
  59. int main(){
  60.     int n, sum, x, xt, c=1, k;
  61.     cout << "Amount of numbers: ";
  62.     cin >> n;
  63.     for(int i = 1; i <= n; i++)
  64.     {
  65.         cin >> x;
  66.         while(c < x)
  67.         {
  68.             if(x%c==0){sum += c;}
  69.             if(sum == x){k++; break;}
  70.             c++;
  71.         }
  72.         c = 1;
  73.         sum = 0;
  74.     }
  75.     cout << "Res: " << k;
  76. }
  77. 5 - сумма же делителей по модулю?
  78. int main(){
  79.     int P = 1, a, b, sum, x, c = 1;
  80.     cin >> a;
  81.     while(b!=1)
  82.     {
  83.         cin >> b;
  84.         while(c!=b)
  85.         {
  86.             if(b%c==0){sum += c;}
  87.             c++;
  88.         }
  89.         c = 1;
  90.         if(a < 0 && sum < 10){P *= a;}
  91.         sum = 0;
  92.         a = b;
  93.     }
  94.     cout << "Res: " << P;
  95. }
  96. 6
  97. int main(){
  98.     int n, sum=0, x, xt, S;
  99.     cout << "Amount of numbers: ";
  100.     cin >> n;
  101.     for(int i = 1; i<=n; i++)
  102.     {
  103.         cin >> x;
  104.         xt = abs(x);
  105.         while(xt != 0)
  106.         {
  107.             sum += xt%10;
  108.             xt /= 10;
  109.         }
  110.         if(sum == 10){S += x;}
  111.         sum = 0;
  112.  
  113.     }
  114.    
  115.     cout << "Res: " << S;
  116. }
  117. 8
  118. int main(){
  119.     int x, k=0, xt, sum;
  120.     while(x != 2)
  121.     {
  122.         cin >> x;
  123.         xt = abs(x);
  124.         while(xt != 0)
  125.         {
  126.             sum += xt % 10;
  127.             xt /= 10;
  128.         }
  129.         if(sum % 5 == 0){k++;}
  130.         sum = 0;
  131.     }
  132.     if(k>=3){cout << "+";}else{cout << "-";}
  133. }
  134. 7
  135. int main(){
  136.     int n, xt, x, k=0;
  137.     cout << "Amount of numbers: ";
  138.     cin >> n;
  139.     for(int i = 1; i <= n; i++)
  140.     {
  141.         cin >> x;
  142.         xt = abs(x);
  143.         while(xt != 0)
  144.         {
  145.             if(xt%10 == 4){k++; break;}
  146.             xt /= 10;
  147.         }
  148.     }
  149.     if(k>=3 && k <= 5){cout << "+";}else{cout << "-";}
  150.  
  151. }
  152. 9
  153. int main(){
  154.     int x=1, sum, max=0, xt;
  155.     while(x!=0)
  156.     {
  157.         cin >> x;
  158.         xt = abs(x);
  159.         while(xt!=0)
  160.         {
  161.             sum += xt%10;
  162.             xt /= 10;
  163.         }
  164.         if(sum>14 && x>max){max = x;}
  165.         sum = 0;
  166.     }
  167.     cout << "Res: ";
  168.     cout << max;
  169.  
  170. }
  171. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement