Compares two strings without repeating a (not a same character)

#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <sstream>
using namespace std;

void i2s(int x, string &basic_string) {
    stringstream ss;
    ss << x;
    ss >> basic_string;
}

bool check(int  x, int xx) {
    string s_x, s_xx;
    i2s(x, s_x);
    i2s(xx, s_xx);
    for (int i = 0; i < s_x.length(); ++i) {
        if (s_xx.find(s_x[i]) != s_xx.npos) {
            return false;
        }
    }
    return true;
}


int main(){
	int x ,x2 ,x3;
	string sx2 , sx3;
	for(x=40 ; x<100;++x){
		x2 = x*x; x3=x*x*x;
		if(check (x2,x3)){
			cout<<x<<"  "<<x2<<"  "<<x3<<endl;	
		}
		
	}
	
	
	return 0 ;
}

  

Guess you like

Origin www.cnblogs.com/Stephen-Jixing/p/12628331.html