Advertisement
Korotkodul

Excel. Перевод в столбец

Nov 29th, 2021
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Online C++ Compiler.
  4. Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10. #include <cmath>
  11. #include <algorithm>
  12. #include <map>
  13. using namespace std;
  14. map <char, int> L;
  15.  
  16. int nm(string x){
  17. reverse(x.begin(), x.end());
  18. int sz = x.size();
  19. int res = 0;
  20. for (int i=0;i<sz;++i){
  21. res += pow(26, i) * L[x[i]];
  22. }
  23. return res;
  24. }
  25.  
  26.  
  27. int main()
  28. {
  29. int cnt = 1;
  30. for (int i = 65; i <= 90;++i){
  31. char l = i;
  32. //cout<<"l= "<<l<<' '<<cnt<<'\n';
  33. L[l] = cnt;
  34. cnt++;
  35. }
  36. //for (auto x: L)cout<<x.first<<' '<<x.second<<'\n';
  37. cout<<nm("AA");
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement