We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aa9cb88 commit a85bd40Copy full SHA for a85bd40
Excel_Sheet_Column.c
@@ -0,0 +1,33 @@
1
+#include <stdio.h>
2
+
3
+void printExcelColumnLabel(int columnNumber) {
4
+ char columnName[50];
5
+ int index = 0;
6
7
+ while (columnNumber > 0) {
8
+ int rem = (columnNumber - 1) % 26;
9
+ columnName[index++] = 'A' + rem;
10
+ columnNumber = (columnNumber - 1) / 26;
11
+ }
12
13
+ columnName[index] = NULL;
14
+ int i, j;
15
+ for (i = 0, j = index - 1; i < j; i++, j--) {
16
+ char temp = columnName[i];
17
+ columnName[i] = columnName[j];
18
+ columnName[j] = temp;
19
20
21
+ printf("%s
22
+", columnName);
23
+}
24
25
+int main() {
26
+ int columnNumber;
27
28
+ scanf("%d", &columnNumber);
29
30
+ printExcelColumnLabel(columnNumber);
31
32
+ return 0;
33
0 commit comments