Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int numOfColumn(char arr[]);
  6.  
  7. int main()
  8. {
  9. char colName[4];
  10.  
  11. cin.getline(colName, 4);
  12.  
  13. int output= numOfColumn(colName);
  14.  
  15. cout << output;
  16.  
  17.  
  18. return 0;
  19. }
  20.  
  21. int numOfColumn(char arr[])
  22. {
  23.  
  24. int colNum = 0;
  25. int index = 0;
  26. int const HELPER = 26;
  27. int counter = 0;
  28.  
  29. if (arr[1] == 0)
  30. {
  31. colNum = arr[0] - '@';
  32. return colNum;
  33. }
  34. else if (arr[2] == 0)
  35. {
  36. int firstNum;
  37. firstNum = arr[0];
  38.  
  39. for (arr[0] = 'A'; arr[0] <= 'Z'; arr[0]++)
  40. {
  41. counter++;
  42.  
  43. if (firstNum == arr[0])
  44. {
  45. firstNum = counter * HELPER;
  46.  
  47. colNum = arr[1] - '@';
  48.  
  49. return firstNum + colNum;
  50. }
  51. }
  52. }
  53. else
  54. {
  55. int secondNum = 0;
  56. int counterTwo = 0;
  57. int counter3 = 0;
  58. secondNum = arr[0];
  59. int helper = 0;
  60. int secondHelper = 0;
  61. int thirdNum = 0;
  62. thirdNum = arr[1];
  63.  
  64. for (arr[0] = 'A'; arr[0] <= 'Z'; arr[0]++)
  65. {
  66. counter3++;
  67.  
  68. if (arr[0] == secondNum)
  69. {
  70. secondHelper = counter3 * HELPER * HELPER;
  71. break;
  72. }
  73. }
  74.  
  75. for (arr[1] = 'A'; arr[1] <= 'Z'; arr[1]++)
  76. {
  77. counterTwo++;
  78.  
  79. if (thirdNum == arr[1])
  80. {
  81. secondNum = counterTwo * HELPER;
  82.  
  83. colNum = arr[2] - '@';
  84.  
  85. helper = secondNum + colNum;
  86.  
  87. }
  88. }
  89.  
  90. return secondHelper + helper;
  91. }
  92.  
  93. return 0;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement