Codeforces Spreadsheets
来源:互联网 发布:淘宝运费险如何设置 编辑:程序博客网 时间:2024/06/05 19:42
import java.util.Scanner;public class Spreadsheets {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int n = scanner.nextInt();for(int i = 0; i < n; i++) {String string = scanner.next();char[] ch = string.toCharArray();int m = ch.length;boolean flag = true;if(ch[0] == 'R' && ch[1] - '0' >=1 && ch[1] - '0' <= 9) {for(int j = 2; j < m; j++) {if(ch[j] == 'C') {flag = false;}}if(!flag) {module1(string);} else {module2(string);}} else {module2(string);}}}public static void module1(String ch) {//检索c的位置int index = ch.indexOf('C');String left = ch.substring(1, index);String right = ch.substring(index+1);int k = Integer.valueOf(right);//System.out.println(k);change(k);System.out.println(str+left);str = "";}public static void module2(String ch) {int i = 0;for(i =0 ; i < ch.length(); i++) {if(ch.charAt(i) - '0' >=1 && ch.charAt(i) - '0' <= 9) {break;}}String left = ch.substring(0, i);String right = ch.substring(i);String ss = "R" + right + "C";int l = left.length();char[] cc = left.toCharArray();int sum = 0;for(int p = 0 ; p < l; p++) {int k = cc[p] - 'A' + 1;int temp = 1;for(int m = 0; m < l-p-1; m++) {temp *= 26;}sum += k * temp;}System.out.println(ss + String.valueOf(sum));}static String str = "";public static void change(int k) {if(k <= 26) {str = (char)('A' + k -1) + str ;return ;} if(k % 26 == 0) {str = 'Z'+ str ;k = k /26 - 1;} else {str =(char)('A' + (k % 26) - 1) + str;//System.out.println(str);k = k / 26;}change(k);}}
阅读全文
0 0
- Codeforces Spreadsheets
- CODEFORCES:1B. Spreadsheets
- CodeForces 1B Spreadsheets
- CodeForces - 1B Spreadsheets
- Codeforces 1B. Spreadsheets
- codeforces--Spreadsheets(模拟)
- codeforces-1B. Spreadsheets
- CodeForces 1B Spreadsheets
- CodeForces#1B Spreadsheets
- Codeforces #1 B. Spreadsheets
- CodeForces 1B Spreadsheets
- codeforces 1B Spreadsheets
- Codeforces 1B Spreadsheets
- codeforces B Spreadsheets
- codeforces--Spreadsheets(模拟)
- Codeforces 1B. Spreadsheets
- Codeforces Round #1B Spreadsheets
- codeforces——B. Spreadsheets
- windows中的eclipse工程在Ubuntu中打开出现中文乱码
- Rigid Body Velocity and Manipulator Jacobian
- 正则表达式
- 4 利用简单分支计算一元二次方程组的根
- 改进旧代码库的推荐路线:可扩展可维护系统的11条经验
- Codeforces Spreadsheets
- 求正整数分解质因数
- 聊聊设计模式(2):享元模式
- java集合框架、集合操作--线性表
- Android之Windows下搭建React Native Android开发环境
- call 和 apply的作用
- 网络攻防技术与实践笔记-信息收集技术手段
- 网络编程代码重用的一点问题与技巧
- 使用 MobX 开发 React Native 应用