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""; for( int i = 0; i < input.size(); ++i ) { std: : wcout < < input[i] < < l"\n"; } std: : wcout < < l""; std: : wcout < < result < < l"\n"; std: : wcout < < l""; 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; }