Using System;
namespace chislaabc
{
class Program
{
static void Main(string[] args)
{
int a, b, c;
Console.WriteLine(“Введите число a”);
a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(“Введите число b”);
b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(“Введите число c”);
c = Convert.ToInt32(Console.ReadLine());
if (a == b || a == c || b == c)
{
Console.WriteLine(«Есть хотя бы одна противоположная пара»);
}
else
{
Console.WriteLine(«Противоположных чисел нет»);
}
Console.ReadKey();
}
}
}
1) #include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> arr;
int N;
int sum = 0;
cin >> N;
for(int i = 0; i<N; ++i) {
int temp;
cin >> temp;
arr.push_back(temp);
if(i==0) {
sum = arr[i];
} else {
sum*=arr[i];
}
cout << "Sum: " << sum;
}
2) #include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> arr;
int N;
cin >> N;
int sum2(0), sum3(0);
for(int i = 0; i<N; ++i) {
int temp;
cin >> temp;
arr.push_back(temp);
if(arr[i]>9&&arr[i]<100) {
if(sum2==0) {
sum2=arr[i];
} else {
sum2*=arr[i];
}
} else {
if(arr[i]>99&&arr[i]<1000) {
sum3+=arr[i];
}
}
}
cout << "Sum2: " << sum2 << endl << "Sum3: " << sum3;
}
х=7690 - условие
var x, L, M: integer;
begin readln(x);
L:=0;
M:=0;
while x > 0 do begin
1) L:= L + 1 = 1;
M:= M + x mod 10 = 0;
x:= x div 10 = 7 69;
2) L:= L + 1 = 2;
M:= M + x mod 10 = 9;
x:= x div 10 = 7 6;
3) L:= L + 1 = 3;
M:= M + x mod 10 = 15;
x:= x div 10 = 7 ;
4) L:= L + 1 = 4;
M:= M + x mod 10 = 22;
x:= x div 10 = 0;
end;
writeln(L);
write(M);
end.
L = 4; M = 22
Объяснение:
1)L:= L + 1 = 0 + 1 = 1;
M:= M + x mod 10 = 0 + 0 (остаток) = 0;
x:= x div 10 = 7690 : 10 = 769 (остаток 0 здесь не пишется);
2)L:= L + 1 = 1 + 1 = 2;
M:= M + x mod 10 = 0 + 9 (остаток) = 9;
x:= x div 10 = 769 : 10 = 76 (остаток 9 здесь не пишется);
3)L:= L + 1 = 2 + 1 = 3;
M:= M + x mod 10 = 9 + 6 (остаток) = 15;
x:= x div 10 = 76 : 10 = 7 (остаток 6 здесь не пишется);
4)L:= L + 1 = 3 + 1 = 4;
M:= M + x mod 10 = 15 + 7 (остаток) = 22;
x:= x div 10 = 7 : 10 = 0 (остаток 7 здесь не пишется);