to 20楼:52的时候输出了B0 而且我觉得也应该是输出B0 或者 BZ 呵呵
如果要是按照19楼所说 应该不是一道简单的26进制问题 老大可否把题目网址发来
我好好研究下
如果要是按照19楼所说 应该不是一道简单的26进制问题 老大可否把题目网址发来
我好好研究下
===========深入<----------------->浅出============
#include<stdio.h> #define R 26 char base[30]="ZABCDEFGHIJKLMNOPQRSTUVWXYZ"; void fun(int N) { int i=0,j; char str[10]; while(N>R) { str[i++]=base[N%R]; N=N%R==0?N/R-1:N/R; } str[i]=base[N]; for(j=i;j>=0;j--) printf("%c",str[j]); printf("\n"); } int main() { int n; while(scanf("%d",&n)!=EOF) fun(n); return 0; }受前面代码启发
#include <stdio.h> int main(void) { unsigned n; int tmp; scanf("%u", &n); /* 输入0就会有意外出现,不过不应该输入0,可以在这里加一条if。*/ tmp = n % 26; while (n != 26 && n / 26) { putchar('A'); n /= 26; } putchar((tmp == 0 ? 25 : tmp - 1) + 'A'); return 0; }
1: A 2: B 3: C 4: D 5: E 6: F 7: G 8: H 9: I 10: J 11: K 12: L 13: M 14: N 15: O 16: P 17: Q 18: R 19: S 20: T 21: U 22: V 23: W 24: X 25: Y 26: Z 27: AA 28: AB 29: AC 30: AD 31: AE 32: AF 33: AG 34: AH 35: AI 36: AJ 37: AK 38: AL 39: AM 40: AN 41: AO 42: AP 43: AQ 44: AR 45: AS 46: AT 47: AU 48: AV 49: AW 50: AX 51: AY 52: AZ