[ create a new paste ] login | about

Link: http://codepad.org/nMEkFmKQ    [ raw code | output | fork ]

yifan666 - C, pasted on Aug 10:
// ABBCCBBA max

import java.util.Scanner;

public class Solution {
	static char s[][];
	static String a;
	static int N, Answer;
	public static void main(String[] args){
		s = new char[100][100];
		Scanner sc = new Scanner(System.in);
        for(int test_case=1; test_case<11; test_case++){
                 N = sc.nextInt();
                sc.nextLine();
                for(int i= 0; i<100; i++){
                    a = sc.nextLine();
                    for(int j=0; j<100; j++){
                        s[i][j] = a.charAt(j);
                    }
                }
                int M=2;
                int max=0;
                for(int i=0; i<100; i++){
                    String b = "";
                    for(int j=0; j<100; j++){
                        b+=s[i][j];
                    }
                    while(M<=100){
                        for(int j=0; j<100-M+1; j++){
                            String c = b.substring(j, j+M);
                            StringBuilder sb = new StringBuilder();
                            sb = sb.append(c);
                            String test = sb.reverse().toString();
                            if(test.equals(c)){
                                max=M;
                                break;
                            }
                        }
                        M++;
                    }
                    M = max;
                }
                
                for(int i=0; i<100; i++){
                    String b = "";
                    for(int j=0; j<100; j++){
                        b+=s[j][i];
                    }
                   	while(M<=100){
						for(int j=0; j<100-M+1; j++){
						String c = b.substring(j, j+M);
						StringBuilder sb = new StringBuilder();
						sb = sb.append(c);
						String test = sb.reverse().toString();
					
						if(test.equals(c)){
							max=M;
							break;
						}
					}
					M++;
				}
				M = max;
             }
		
		System.out.println("#" +test_case+ " " + M );
        }
		
	}
}


Output:
1
2
Line 3: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'java'
Line 5: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'class'


Create a new paste based on this one


Comments: