fojtasd

Untitled

Jul 12th, 2019
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.46 KB | None | 0 0
  1. int commonChild(string s1, string s2)
  2. {
  3.     int counterA = 0;
  4.     int counterB = 0;
  5.     int counterC = 0;
  6.     int counterD = 0;
  7.     int counterE = 0;
  8.     int counterF = 0;
  9.     int counterG = 0;
  10.     int counterH = 0;
  11.     int counterI = 0;
  12.     int counterJ = 0;
  13.     int counterK = 0;
  14.     int counterL = 0;
  15.     int counterM = 0;
  16.     int counterN = 0;
  17.     int counterO = 0;
  18.     int counterP = 0;
  19.     int counterQ = 0;
  20.     int counterR = 0;
  21.     int counterS = 0;
  22.     int counterT = 0;
  23.     int counterU = 0;
  24.     int counterV = 0;
  25.     int counterW = 0;
  26.     int counterX = 0;
  27.     int counterY = 0;
  28.     int counterZ = 0;
  29.  
  30.     int counterA1 = 0;
  31.     int counterB1 = 0;
  32.     int counterC1 = 0;
  33.     int counterD1 = 0;
  34.     int counterE1 = 0;
  35.     int counterF1 = 0;
  36.     int counterG1 = 0;
  37.     int counterH1 = 0;
  38.     int counterI1 = 0;
  39.     int counterJ1 = 0;
  40.     int counterK1 = 0;
  41.     int counterL1 = 0;
  42.     int counterM1 = 0;
  43.     int counterN1 = 0;
  44.     int counterO1 = 0;
  45.     int counterP1 = 0;
  46.     int counterQ1 = 0;
  47.     int counterR1 = 0;
  48.     int counterS1 = 0;
  49.     int counterT1 = 0;
  50.     int counterU1 = 0;
  51.     int counterV1 = 0;
  52.     int counterW1 = 0;
  53.     int counterX1 = 0;
  54.     int counterY1 = 0;
  55.     int counterZ1 = 0;
  56.     int counterCommon = 0;
  57.  
  58.    
  59.     for (int i = 0; i < s1.length(); i++){
  60.         switch(s1[i]){
  61.         case 'A': counterA++;   break;
  62.         case 'B': counterB++;   break;
  63.         case 'C': counterC++;   break;
  64.         case 'D': counterD++;   break;
  65.         case 'E': counterE++;   break;
  66.         case 'F': counterF++;   break;
  67.         case 'G': counterG++;   break;
  68.         case 'H': counterH++;   break;
  69.         case 'I': counterI++;   break;
  70.         case 'J': counterJ++;   break;
  71.         case 'K': counterK++;   break;
  72.         case 'L': counterL++;   break;
  73.         case 'M': counterM++;   break;
  74.         case 'N': counterN++;   break;
  75.         case 'O': counterO++;   break;
  76.         case 'P': counterP++;   break;
  77.         case 'Q': counterQ++;   break;
  78.         case 'R': counterR++;   break;
  79.         case 'S': counterS++;   break;
  80.         case 'T': counterT++;   break;
  81.         case 'U': counterU++;   break;
  82.         case 'V': counterV++;   break;
  83.         case 'W': counterW++;   break;
  84.         case 'X': counterX++;   break;
  85.         case 'Y': counterY++;   break;
  86.         case 'Z': counterZ++;   break;
  87.         }
  88.     }
  89.  
  90.     for (int i = 0; i < s2.length(); i++){
  91.         switch(s2[i]){
  92.         case 'A': counterA1++;   break;
  93.         case 'B': counterB1++;   break;
  94.         case 'C': counterC1++;   break;
  95.         case 'D': counterD1++;   break;
  96.         case 'E': counterE1++;   break;
  97.         case 'F': counterF1++;   break;
  98.         case 'G': counterG1++;   break;
  99.         case 'H': counterH1++;   break;
  100.         case 'I': counterI1++;   break;
  101.         case 'J': counterJ1++;   break;
  102.         case 'K': counterK1++;   break;
  103.         case 'L': counterL1++;   break;
  104.         case 'M': counterM1++;   break;
  105.         case 'N': counterN1++;   break;
  106.         case 'O': counterO1++;   break;
  107.         case 'P': counterP1++;   break;
  108.         case 'Q': counterQ1++;   break;
  109.         case 'R': counterR1++;   break;
  110.         case 'S': counterS1++;   break;
  111.         case 'T': counterT1++;   break;
  112.         case 'U': counterU1++;   break;
  113.         case 'V': counterV1++;   break;
  114.         case 'W': counterW1++;   break;
  115.         case 'X': counterX1++;   break;
  116.         case 'Y': counterY1++;   break;
  117.         case 'Z': counterZ1++;   break;
  118.         }
  119.     }
  120.  
  121.     if (counterA > counterA1){
  122.         counterCommon+=counterA1;
  123.     }
  124.     else counterCommon+=counterA;
  125.  
  126.     if (counterB > counterB1){
  127.         counterCommon+=counterB1;
  128.     }
  129.     else counterCommon+=counterB;
  130.    
  131.     if (counterC > counterC1){
  132.         counterCommon+=counterC1;
  133.     }
  134.     else counterCommon+=counterC;
  135.    
  136.     if (counterD > counterD1){
  137.         counterCommon+=counterD1;
  138.     }
  139.     else counterCommon+=counterE;
  140.    
  141.     if (counterE > counterE1){
  142.         counterCommon+=counterE1;
  143.     }
  144.     else counterCommon+=counterE;
  145.    
  146.     if (counterF > counterF1){
  147.         counterCommon+=counterF1;
  148.     }
  149.     else counterCommon+=counterF;
  150.    
  151.     if (counterG > counterG1){
  152.         counterCommon+=counterG1;
  153.     }
  154.     else counterCommon+=counterG;
  155.    
  156.     if (counterH > counterH1){
  157.         counterCommon+=counterH1;
  158.     }
  159.     else counterCommon+=counterH;
  160.    
  161.     if (counterI > counterI1){
  162.         counterCommon+=counterI1;
  163.     }
  164.     else counterCommon+=counterI;
  165.    
  166.     if (counterJ > counterJ1){
  167.         counterCommon+=counterJ1;
  168.     }
  169.     else counterCommon+=counterJ;
  170.    
  171.     if (counterK > counterK1){
  172.         counterCommon+=counterK1;
  173.     }
  174.     else counterCommon+=counterK;
  175.    
  176.     if (counterL > counterL1){
  177.         counterCommon+=counterL1;
  178.     }
  179.     else counterCommon+=counterL;
  180.    
  181.     if (counterM > counterM1){
  182.         counterCommon+=counterM1;
  183.     }
  184.     else counterCommon+=counterM;
  185.  
  186.    
  187.     if (counterN > counterN1){
  188.         counterCommon+=counterN1;
  189.     }
  190.     else counterCommon+=counterN;
  191.  
  192.  
  193.     if (counterO > counterO1){
  194.         counterCommon+=counterO1;
  195.     }
  196.     else counterCommon+=counterO;
  197.  
  198.    
  199.     if (counterP > counterP1){
  200.         counterCommon+=counterP1;
  201.     }
  202.     else counterCommon+=counterP;
  203.  
  204.    
  205.     if (counterQ > counterQ1){
  206.         counterCommon+=counterQ1;
  207.     }
  208.     else counterCommon+=counterQ;
  209.  
  210.    
  211.     if (counterR > counterR1){
  212.         counterCommon+=counterR1;
  213.     }
  214.     else counterCommon+=counterR;
  215.  
  216.    
  217.     if (counterS > counterS1){
  218.         counterCommon+=counterS1;
  219.     }
  220.     else counterCommon+=counterS;
  221.  
  222.    
  223.     if (counterT > counterT1){
  224.         counterCommon+=counterT1;
  225.     }
  226.     else counterCommon+=counterT;
  227.  
  228.    
  229.     if (counterU > counterU1){
  230.         counterCommon+=counterU1;
  231.     }
  232.     else counterCommon+=counterU;
  233.  
  234.    
  235.     if (counterV > counterV1){
  236.         counterCommon+=counterV1;
  237.     }
  238.     else counterCommon+=counterV;
  239.  
  240.    
  241.     if (counterW > counterW1){
  242.         counterCommon+=counterW1;
  243.     }
  244.     else counterCommon+=counterW;
  245.  
  246.    
  247.     if (counterX > counterX1){
  248.         counterCommon+=counterX1;
  249.     }
  250.     else counterCommon+=counterX;
  251.  
  252.    
  253.     if (counterY > counterY1){
  254.         counterCommon+=counterY1;
  255.     }
  256.     else counterCommon+=counterY;
  257.  
  258.    
  259.     if (counterZ > counterZ1){
  260.         counterCommon+=counterZ1;
  261.     }
  262.     else counterCommon+=counterZ;
  263.  
  264.     return counterCommon;
  265. }
Advertisement
Add Comment
Please, Sign In to add comment