fork download
  1. import java.util.Scanner;
  2. public class spreadsheets
  3. {
  4. public static void main(String[] args)
  5. {
  6. Scanner sc= new Scanner(System.in);
  7. long n = sc.nextLong();
  8. long[] row_arr = new long[99999];
  9. long[] col_arr = new long[99999];
  10. String[] store = new String[9999];
  11. for(int l=0;l<n;l++)
  12. {
  13. store[l] = sc.next();
  14. }
  15. for(int i=0;i<n;i++)
  16. {
  17. long row =0; long col=0;
  18. int c1=0; int c2=1; int c3=0;int c4=0;
  19. store[i] = store[i] + '\0';
  20. char c = store[i].charAt(0);
  21. char d = store[i].charAt(1);
  22. if(c=='R' && (int)d <65)
  23. {
  24. while(store[i].charAt(c2) !='C')
  25. {
  26. row_arr[c1] = (Integer.valueOf((store[i].charAt(c2))-48));
  27. c1++;
  28. c2++;
  29. }
  30. c1=c1-1;
  31. do
  32. {
  33. row = row_arr[c3]*(long)Math.pow(10, c1) + row;
  34. c1--;
  35. c3++;
  36. }while(c1>=0);
  37. c2++;
  38. c1=0;
  39. c3=0;
  40. while(store[i].charAt(c2) !='\0')
  41. {
  42. col_arr[c1] = Integer.valueOf(store[i].charAt(c2)-48);
  43. c1++;
  44. c2++;
  45. }
  46. c1=c1-1;
  47. do
  48. {
  49. col = col_arr[c3]*(int)Math.pow(10, c1) + col;
  50. c1--;
  51. c3++;
  52. }while(c1>=0);
  53. while(true)
  54. {
  55. if(col%26==0)
  56. {
  57. if(col<=Math.pow(27, c4))
  58. break;
  59. else
  60. c4++;
  61.  
  62. }
  63. else if(col%26!=0)
  64. {
  65. if((col<Math.pow(27, c4)))
  66. break;
  67. else
  68. c4++;
  69. }
  70. }
  71. char[] col_name = new char[c4];
  72. for(int k=(c4-1);k>=0;k--)
  73. {
  74. if(col%26==0)
  75. {
  76. col_name[k] = (char)((col%26) + 90);
  77. col=col-1;
  78. }
  79. else
  80. col_name[k] = (char)((col%26) + 64);
  81. col= (col/26);
  82. }
  83. for(int j=0;j<c4;j++)
  84. {
  85. System.out.print((col_name[j]));
  86. }
  87. System.out.print(row);
  88. System.out.println();
  89. }
  90. else
  91. {
  92. int e=0; int f=0; double sum =0;int temp =0;
  93. int[] rev = new int[99999];
  94. while(store[i].charAt(e)>=65)
  95. {
  96. rev[e] = (store[i].charAt(e))-64;
  97. e++;
  98.  
  99. }
  100. temp=e;
  101. for(int m=e;m>0;m--)
  102. {
  103. sum = rev[f]*Math.pow(26, (double)(m-1))+sum;
  104. e--;
  105. f++;
  106. }
  107. System.out.print("R");
  108. while(store[i].charAt(temp)!='\0')
  109. {
  110. System.out.print(store[i].charAt(temp)-48);
  111. temp++;
  112.  
  113. }System.out.println("C"+(int)sum);
  114. }
  115.  
  116. }
  117.  
  118.  
  119. }
  120. }
  121.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:2: error: class spreadsheets is public, should be declared in a file named spreadsheets.java
						public class spreadsheets
						       ^
1 error
stdout
Standard output is empty