Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int numOfColumn(char arr[]);
- int main()
- {
- char colName[4];
- cin.getline(colName, 4);
- int output= numOfColumn(colName);
- cout << output;
- return 0;
- }
- int numOfColumn(char arr[])
- {
- int colNum = 0;
- int index = 0;
- int const HELPER = 26;
- int counter = 0;
- if (arr[1] == 0)
- {
- colNum = arr[0] - '@';
- return colNum;
- }
- else if (arr[2] == 0)
- {
- int firstNum;
- firstNum = arr[0];
- for (arr[0] = 'A'; arr[0] <= 'Z'; arr[0]++)
- {
- counter++;
- if (firstNum == arr[0])
- {
- firstNum = counter * HELPER;
- colNum = arr[1] - '@';
- return firstNum + colNum;
- }
- }
- }
- else
- {
- int secondNum = 0;
- int counterTwo = 0;
- int counter3 = 0;
- secondNum = arr[0];
- int helper = 0;
- int secondHelper = 0;
- int thirdNum = 0;
- thirdNum = arr[1];
- for (arr[0] = 'A'; arr[0] <= 'Z'; arr[0]++)
- {
- counter3++;
- if (arr[0] == secondNum)
- {
- secondHelper = counter3 * HELPER * HELPER;
- break;
- }
- }
- for (arr[1] = 'A'; arr[1] <= 'Z'; arr[1]++)
- {
- counterTwo++;
- if (thirdNum == arr[1])
- {
- secondNum = counterTwo * HELPER;
- colNum = arr[2] - '@';
- helper = secondNum + colNum;
- }
- }
- return secondHelper + helper;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement