답안 #584210

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
584210 2022-06-27T04:07:23 Z Shubham_4070 Karte (COCI15_karte) Java 11
컴파일 오류
0 ms 0 KB
public class Main
{
  int suite(char ch){
    if(ch=='P')return 0;
    if(ch=='K')return 1;
     if(ch=='H')return 2;
    return 3;
  }
  int num(String str){
    int res=0;
    for(int i=0;i<=1;i++)
    {
      char ch=str.charAt(i);
       res=res*10+(ch-'0');   
    }
    return res;
  }
	public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);
       String str=ob.next();
      int vis[][]=new int[4][14];
        for(int i=0;i<n;i+=3){
          char ch=str.charAt(i);
          int st=suite(ch);
          int m=num(str.substring(i+1,i+3));
          if(vis[st][m]==1)
          {
            System.out.print("Greeka");
            return;
          }
          else
            vis[st][m]=1;
           }
      //missing
      int ans[]=new int[n/3];
      for(int i=0;i<=3;i++){
        ans[i]=13;
        for(int j=1;j<=13;j++){
            ans[i]=ans[i]-vis[i][j];
        }
      }
      //print the array
      for(int i=0;i<ans.length;i++){
        System.out.print(ans[i]+" ");
      }
      
      
	}
}

Compilation message

karte.java:1: error: class Main is public, should be declared in a file named Main.java
public class Main
       ^
karte.java:19: error: cannot find symbol
		Scanner ob=new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
karte.java:19: error: cannot find symbol
		Scanner ob=new Scanner(System.in);
		               ^
  symbol:   class Scanner
  location: class Main
karte.java:22: error: cannot find symbol
        for(int i=0;i<n;i+=3){
                      ^
  symbol:   variable n
  location: class Main
karte.java:24: error: non-static method suite(char) cannot be referenced from a static context
          int st=suite(ch);
                 ^
karte.java:25: error: non-static method num(String) cannot be referenced from a static context
          int m=num(str.substring(i+1,i+3));
                ^
karte.java:35: error: cannot find symbol
      int ans[]=new int[n/3];
                        ^
  symbol:   variable n
  location: class Main
7 errors