Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int commonChild(string s1, string s2)
- {
- int counterA = 0;
- int counterB = 0;
- int counterC = 0;
- int counterD = 0;
- int counterE = 0;
- int counterF = 0;
- int counterG = 0;
- int counterH = 0;
- int counterI = 0;
- int counterJ = 0;
- int counterK = 0;
- int counterL = 0;
- int counterM = 0;
- int counterN = 0;
- int counterO = 0;
- int counterP = 0;
- int counterQ = 0;
- int counterR = 0;
- int counterS = 0;
- int counterT = 0;
- int counterU = 0;
- int counterV = 0;
- int counterW = 0;
- int counterX = 0;
- int counterY = 0;
- int counterZ = 0;
- int counterA1 = 0;
- int counterB1 = 0;
- int counterC1 = 0;
- int counterD1 = 0;
- int counterE1 = 0;
- int counterF1 = 0;
- int counterG1 = 0;
- int counterH1 = 0;
- int counterI1 = 0;
- int counterJ1 = 0;
- int counterK1 = 0;
- int counterL1 = 0;
- int counterM1 = 0;
- int counterN1 = 0;
- int counterO1 = 0;
- int counterP1 = 0;
- int counterQ1 = 0;
- int counterR1 = 0;
- int counterS1 = 0;
- int counterT1 = 0;
- int counterU1 = 0;
- int counterV1 = 0;
- int counterW1 = 0;
- int counterX1 = 0;
- int counterY1 = 0;
- int counterZ1 = 0;
- int counterCommon = 0;
- for (int i = 0; i < s1.length(); i++){
- switch(s1[i]){
- case 'A': counterA++; break;
- case 'B': counterB++; break;
- case 'C': counterC++; break;
- case 'D': counterD++; break;
- case 'E': counterE++; break;
- case 'F': counterF++; break;
- case 'G': counterG++; break;
- case 'H': counterH++; break;
- case 'I': counterI++; break;
- case 'J': counterJ++; break;
- case 'K': counterK++; break;
- case 'L': counterL++; break;
- case 'M': counterM++; break;
- case 'N': counterN++; break;
- case 'O': counterO++; break;
- case 'P': counterP++; break;
- case 'Q': counterQ++; break;
- case 'R': counterR++; break;
- case 'S': counterS++; break;
- case 'T': counterT++; break;
- case 'U': counterU++; break;
- case 'V': counterV++; break;
- case 'W': counterW++; break;
- case 'X': counterX++; break;
- case 'Y': counterY++; break;
- case 'Z': counterZ++; break;
- }
- }
- for (int i = 0; i < s2.length(); i++){
- switch(s2[i]){
- case 'A': counterA1++; break;
- case 'B': counterB1++; break;
- case 'C': counterC1++; break;
- case 'D': counterD1++; break;
- case 'E': counterE1++; break;
- case 'F': counterF1++; break;
- case 'G': counterG1++; break;
- case 'H': counterH1++; break;
- case 'I': counterI1++; break;
- case 'J': counterJ1++; break;
- case 'K': counterK1++; break;
- case 'L': counterL1++; break;
- case 'M': counterM1++; break;
- case 'N': counterN1++; break;
- case 'O': counterO1++; break;
- case 'P': counterP1++; break;
- case 'Q': counterQ1++; break;
- case 'R': counterR1++; break;
- case 'S': counterS1++; break;
- case 'T': counterT1++; break;
- case 'U': counterU1++; break;
- case 'V': counterV1++; break;
- case 'W': counterW1++; break;
- case 'X': counterX1++; break;
- case 'Y': counterY1++; break;
- case 'Z': counterZ1++; break;
- }
- }
- if (counterA > counterA1){
- counterCommon+=counterA1;
- }
- else counterCommon+=counterA;
- if (counterB > counterB1){
- counterCommon+=counterB1;
- }
- else counterCommon+=counterB;
- if (counterC > counterC1){
- counterCommon+=counterC1;
- }
- else counterCommon+=counterC;
- if (counterD > counterD1){
- counterCommon+=counterD1;
- }
- else counterCommon+=counterE;
- if (counterE > counterE1){
- counterCommon+=counterE1;
- }
- else counterCommon+=counterE;
- if (counterF > counterF1){
- counterCommon+=counterF1;
- }
- else counterCommon+=counterF;
- if (counterG > counterG1){
- counterCommon+=counterG1;
- }
- else counterCommon+=counterG;
- if (counterH > counterH1){
- counterCommon+=counterH1;
- }
- else counterCommon+=counterH;
- if (counterI > counterI1){
- counterCommon+=counterI1;
- }
- else counterCommon+=counterI;
- if (counterJ > counterJ1){
- counterCommon+=counterJ1;
- }
- else counterCommon+=counterJ;
- if (counterK > counterK1){
- counterCommon+=counterK1;
- }
- else counterCommon+=counterK;
- if (counterL > counterL1){
- counterCommon+=counterL1;
- }
- else counterCommon+=counterL;
- if (counterM > counterM1){
- counterCommon+=counterM1;
- }
- else counterCommon+=counterM;
- if (counterN > counterN1){
- counterCommon+=counterN1;
- }
- else counterCommon+=counterN;
- if (counterO > counterO1){
- counterCommon+=counterO1;
- }
- else counterCommon+=counterO;
- if (counterP > counterP1){
- counterCommon+=counterP1;
- }
- else counterCommon+=counterP;
- if (counterQ > counterQ1){
- counterCommon+=counterQ1;
- }
- else counterCommon+=counterQ;
- if (counterR > counterR1){
- counterCommon+=counterR1;
- }
- else counterCommon+=counterR;
- if (counterS > counterS1){
- counterCommon+=counterS1;
- }
- else counterCommon+=counterS;
- if (counterT > counterT1){
- counterCommon+=counterT1;
- }
- else counterCommon+=counterT;
- if (counterU > counterU1){
- counterCommon+=counterU1;
- }
- else counterCommon+=counterU;
- if (counterV > counterV1){
- counterCommon+=counterV1;
- }
- else counterCommon+=counterV;
- if (counterW > counterW1){
- counterCommon+=counterW1;
- }
- else counterCommon+=counterW;
- if (counterX > counterX1){
- counterCommon+=counterX1;
- }
- else counterCommon+=counterX;
- if (counterY > counterY1){
- counterCommon+=counterY1;
- }
- else counterCommon+=counterY;
- if (counterZ > counterZ1){
- counterCommon+=counterZ1;
- }
- else counterCommon+=counterZ;
- return counterCommon;
- }
Advertisement
Add Comment
Please, Sign In to add comment