[ create a new paste ] login | about

Link: http://codepad.org/MHZN5Uyp    [ raw code | output | fork ]

C++, pasted on Oct 31:
#include <string>
#include <iostream>
using namespace std;

int main()
{
	size_t i, j;
	string str1 = "ab125cdEfKOWg";
	string str2 = "rtydeb";
	string sout;

	cout<<"str1 : "<<str1<<endl;
	cout<<"str2 : "<<str2<<endl;
	for( i = 0; i < str1.length(); i++ )
	{
		if( isalpha(str1[i]) )//символ является буквой?
		if( islower(str1[i]) )//строчная ли буква
		if( str2.find(str1[i], 0) == string::npos )//Ищем символ не входящий во 2-ую строку
		if( sout.find(str1[i], 0) == string::npos )//Выходная строка не содержит указанный символ
			sout += str1[i];
	}

	//Сортировка
	for( i = 0;     i < sout.length(); i++ )
	for( j = i + 1; j < sout.length(); j++ )
	{
		if( sout[i] < sout[j] )
			swap(sout[i], sout[j]);
	}
	cout<<"sout : "<<sout<<endl;
	cin.get();
	return 0;
}


Output:
1
2
3
str1 : ab125cdEfKOWg
str2 : rtydeb
sout : gfca


Create a new paste based on this one


Comments: