var a:string;beginreadln(a);writeln(a[3],a[4],a[5],a[6],a[9],a[11]);writeln(a[4],a[5],a[6],a[3]);writeln(a[4],a[6],a[5],a[1],a[3],a[4]);end.
var a,b,c:string;beginreadln(a,b,c);writeln(a[1],c[2],a[2],b[1],c[1]);end.
var a:string; i:integer;beginreadln(a);while pos('М',a)<>0 do begininc(i);delete(a,pos('М',a),1);end;writeln(i);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:string;
begin
readln(a);
writeln(a[3],a[4],a[5],a[6],a[9],a[11]);
writeln(a[4],a[5],a[6],a[3]);
writeln(a[4],a[6],a[5],a[1],a[3],a[4]);
end.
var a,b,c:string;
begin
readln(a,b,c);
writeln(a[1],c[2],a[2],b[1],c[1]);
end.
var a:string; i:integer;
begin
readln(a);
while pos('М',a)<>0 do begin
inc(i);
delete(a,pos('М',a),1);
end;
writeln(i);
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;
}