Chúng tôi đã thảo luận Chuyển đổi từ số cột sang tên cột Excel. Trong bài viết này, đảo ngược được thảo luận
Đưa ra một tiêu đề cột như xuất hiện trong một trang tính Excel, hãy trả về số cột tương ứng của nó
column column number A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28
ví dụ.
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.
Đề nghị thực hành
Bảng tính Excel. Phần 2
Thử nó
Cách tiếp cận. Quá trình này tương tự như chuyển đổi nhị phân sang thập phân.
Ví dụ, để chuyển đổi AB, công thức là 26 * 1 + 2.
Như một ví dụ khác,
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1
Vì vậy, nó rất giống với việc chuyển đổi nhị phân sang thập phân giữ cơ số là 26.
Lấy đầu vào dưới dạng chuỗi và duyệt chuỗi đầu vào từ trái sang phải và tính toán kết quả như sau.
result = 26*result + s[i] - 'A' + 1
Kết quả sẽ là tổng của
Thực hiện
C++
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 115
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 116
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 117
________ 218 ________ 219 ________ 10
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.1
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.2
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.3
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.4
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.6
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.8
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.2
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 11
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 13
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 14
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 15
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 16
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 17
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.4
result = 26*result + s[i] - 'A' + 10
result = 26*result + s[i] - 'A' + 11
result = 26*result + s[i] - 'A' + 10
result = 26*result + s[i] - 'A' + 13
result = 26*result + s[i] - 'A' + 14
result = 26*result + s[i] - 'A' + 15
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
result = 26*result + s[i] - 'A' + 17
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
result = 26*result + s[i] - 'A' + 19
result = 26*result + s[i] - 'A' + 140
result = 26*result + s[i] - 'A' + 17
result = 26*result + s[i] - 'A' + 142
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.2
result = 26*result + s[i] - 'A' + 144
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.4
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
result = 26*result + s[i] - 'A' + 147____348
result = 26*result + s[i] - 'A' + 149
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
result = 26*result + s[i] - 'A' + 19
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1152
result = 26*result + s[i] - 'A' + 17
Java
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1154
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1155
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1156
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1157
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1156
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1159
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1160
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1161
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.4
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.1
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1164
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.2
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1166
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.4
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.6
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.8
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.2
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1174
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1175
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1176
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 13
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 14
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.2
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1181
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1175
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1183
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.4
result = 26*result + s[i] - 'A' + 10____2187____2188
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1176
result = 26*result + s[i] - 'A' + 10______2191______34
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1193
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1194
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1176
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
result = 26*result + s[i] - 'A' + 17
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
result = 26*result + s[i] - 'A' + 19
result = 26*result + s[i] - 'A' + 140
result = 26*result + s[i] - 'A' + 17
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.03
________ 104 ________ 2164 ________ 106 ________ 107
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.4
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.10____348
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.12
result = 26*result + s[i] - 'A' + 17
result = 26*result + s[i] - 'A' + 17
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.15
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.16
Python3
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.17
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.18
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.19
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.20
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.21
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.23
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.25
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.27____128
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1175
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1176
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 13
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.33
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.34
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.35
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 14
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.37
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.38
result = 26*result + s[i] - 'A' + 10______127
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.41
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.28
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1188
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1176
result = 26*result + s[i] - 'A' + 10______127
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1193
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.28
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.49
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.50
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.51
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.49
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 14
result = 26*result + s[i] - 'A' + 14
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.55
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1193
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1194
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1176
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
result = 26*result + s[i] - 'A' + 19
result = 26*result + s[i] - 'A' + 140
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.62
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.63
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.64
result = 26*result + s[i] - 'A' + 148
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.12
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.67
C#
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.68
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1155
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 118
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.71
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1160
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1161
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.4
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.1
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.04
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1164
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.2
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.79
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.80
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.81
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.4
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.6
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.8
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.2
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 11
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 13
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 14
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.2
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.94
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.4
result = 26*result + s[i] - 'A' + 10
result = 26*result + s[i] - 'A' + 11
result = 26*result + s[i] - 'A' + 10____200____34
result = 26*result + s[i] - 'A' + 15
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
result = 26*result + s[i] - 'A' + 17
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
result = 26*result + s[i] - 'A' + 19
result = 26*result + s[i] - 'A' + 140
result = 26*result + s[i] - 'A' + 17
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.03
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.04
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1164
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.06
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 113
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.80
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 115
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.4
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 118
result = 26*result + s[i] - 'A' + 148
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.12
result = 26*result + s[i] - 'A' + 17
result = 26*result + s[i] - 'A' + 17
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 123
Javascript
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 124
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 125
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 1155
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 127
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 128
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 129
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.4
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.6
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.8
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 136
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 13
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 139
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.4
result = 26*result + s[i] - 'A' + 10
result = 26*result + s[i] - 'A' + 11
result = 26*result + s[i] - 'A' + 10____245____34
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 147
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
result = 26*result + s[i] - 'A' + 17
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.5
result = 26*result + s[i] - 'A' + 19
result = 26*result + s[i] - 'A' + 140
result = 26*result + s[i] - 'A' + 17
Input: A Output: 1 A is the first column so the output is 1. Input: AA Output: 27 The columns are in order A, B, ..., Y, Z, AA .. So, there are 26 columns after which AA comes.03
________ 255 ________ 348 ________ 112
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 158
To convert CDA, 3*26*26 + 4*26 + 1 = 26[3*26 + 4] + 1 = 26[0*26 + 3*26 + 4] + 159
Đầu ra
result = 26*result + s[i] - 'A' + 14
Phân tích độ phức tạp.
- Thời gian phức tạp. O[n], trong đó n là độ dài của chuỗi đầu vào
- Độ phức tạp của không gian. Ô[1].
Vì không cần thêm dung lượng.
Bài viết này được đóng góp bởi Sahil Rajput. Nếu bạn thích GeeksforGeeks và muốn đóng góp, bạn cũng có thể viết một bài báo bằng cách sử dụng write. chuyên viên máy tính. org hoặc gửi bài viết của bạn tới review-team@geeksforgeeks. tổ chức. Xem bài viết của bạn xuất hiện trên trang chính của GeeksforGeeks và trợ giúp các Geeks khác