var a:array[1..10,1..10]of integer; b:array[1..10,1..10]of integer; i,j,s1,s2:integer; begin for i:=1 to 10 do for j:=1 to 10 do begin a[i,j]:=random(9)+1; b[i,j]:=random(9)+1; end; for i:=1 to 10 do begin for j:=1 to 10 do write(a[i,j],' '); if j=10 then writeln; end; writeln; for i:=1 to 10 do begin for j:=1 to 10 do write(b[i,j],' '); if j=10 then writeln; end; for i:=1 to 10 do for j:=1 to 10 do if i=j then begin s1:=s1+a[i,j]; s2:=s2+b[i,j]; end; writeln; if s1>s2 then for i:=1 to 10 do begin for j:=1 to 10 do write(a[i,j],' '); if j=10 then writeln; end else for i:=1 to 10 do begin for j:=1 to 10 do write(b[i,j],' '); if j=10 then writeln; end; end.
странное задание, но все же:
#include <string>
#include <vector>
#include <iostream>
bool compose( std::vector<std::wstring> &input, std::wstring result )
{
for( int i = 0; i < result.size(); ++i ) {
bool found( false );
for( int j = 0; j < input.size(); ++j ) {
if( input[j].find( result[i] ) != -1 ) {
found = true;
input[j].erase( input[j].begin() + input[j].find( result[i] ) );
}
}
if( found == false )
return false;
}
std::wcout << L"\n";
for( int i = 0; i < input.size(); ++i )
{
std::wcout << input[i] << L"\n";
}
std::wcout << L"\n";
std::wcout << result << L"\n";
std::wcout << L"\n";
return true;
}
int main(int argc, wchar_t* argv[])
{
std::vector<std::wstring> v1;
v1.push_back( L"ИНСТРУМЕНТЫ" );
compose( v1, L"СТРУНЫ" );
std::vector<std::wstring> v2;
v2.push_back( L"ИНСТРУМЕНТЫ" );
compose( v2, L"ТРУС" );
std::vector<std::wstring> v3;
v3.push_back( L"ИНСТРУМЕНТЫ" );
compose( v3, L"ТУРИСТ" );
std::vector<std::wstring> v4;
v4.push_back( L"ШИШКА" );
v4.push_back( L"ФЛАГ" );
v4.push_back( L"ТРОС" );
compose( v4, L"ШРИФТ" );
std::wstring text;
std::wcout << L"\nТекст:";
std::wcin >> text;
int count = 0;
for( int i = 0; i < text.size(); ++i ) {
if( text[i] == L'M' )
++count;
}
std::wcout << L"\nколичество M: " << count;
return 0;
}
var a:array[1..10,1..10]of integer;
b:array[1..10,1..10]of integer;
i,j,s1,s2:integer;
begin
for i:=1 to 10 do for j:=1 to 10 do begin a[i,j]:=random(9)+1; b[i,j]:=random(9)+1; end;
for i:=1 to 10 do begin for j:=1 to 10 do write(a[i,j],' '); if j=10 then writeln; end;
writeln;
for i:=1 to 10 do begin for j:=1 to 10 do write(b[i,j],' '); if j=10 then writeln; end;
for i:=1 to 10 do
for j:=1 to 10 do
if i=j then begin
s1:=s1+a[i,j];
s2:=s2+b[i,j];
end;
writeln;
if s1>s2 then for i:=1 to 10 do begin for j:=1 to 10 do write(a[i,j],' '); if j=10 then writeln; end else
for i:=1 to 10 do begin for j:=1 to 10 do write(b[i,j],' '); if j=10 then writeln; end;
end.