Подскажите ! сколько единиц в двоичной записи десятичного числа 92? сколько нулей в двоичной записи десятичного числа 88? перевести число 111 из 10сс в 2сс. перевести числа 1101010; 111000 и 10101101 из 2сс в 10сс!
// PascalABC.NET 3.0, сборка 1073 const sb='bcdfgjklmnpqrstvwxz'; s='Computer programming is a process of computer programs creation'; var i,n:integer; s1,sn,t:string; begin i:=1; while s[i]<>' ' do Inc(i); s1:=Copy(s,1,i-1); n:=Length(s); i:=n; while s[i]<>' ' do Dec(i); sn:=Copy(s,i+1,n-i); t:=''; for i:=1 to Length(s1) do if Pos(s1[i],sb)>0 then t:=t+s1[i]; s1:=t; t:=''; for i:=1 to Length(sn) do if Pos(sn[i],sb)>0 then t:=t+sn[i]; sn:=t; t:=''; for i:=1 to Length(s1) do if Pos(s1[i],sn)>0 then if Pos(s1[i],t)=0 then t:=t+s1[i]; for i:=1 to Length(t) do Write(t[i],' '); Writeln end.
Тестовый прогон: t r
2. "Нормальное" решение
// PascalABC.NET 3.0, сборка 1073 const sb='bcdfgjklmnpqrstvwxz'; s='Computer programming is a process of computer programs creation'; begin var a:=s.ToWords(' '); a[0].Intersect(a[a.Length-1]).Where(x->Pos(x,sb)>0).Println(',') end.
Тестовый прогон: t,r
merx80
29.09.2020
#include <iostream> #include <conio.h> using namespace std;
int main() { setlocale(LC_ALL,"Russian"); const int N=7; int A[N]; cout << "Введите массив, состоящий из " << N << " элементов:\n"; for (int i=0; i<N; i++) cin >> A[i]; cout << "Массив до - "; for (int i=0; i<N; i++) { cout << A[i] << " "; if (A[i]*A[i] < 25) A[i] *= 2; } cout << "\nМассив после - "; for (int i=0; i<N; i++) cout << A[i] << " "; _getch(); return 0; }