답안 #584211

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
584211 2022-06-27T04:09:56 Z Shubham_4070 Karte (COCI15_karte) Java 11
컴파일 오류
0 ms 0 KB
import java.util.*;
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];
      int n=str.length();
        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:2: error: class Main is public, should be declared in a file named Main.java
public class Main
       ^
karte.java:26: error: non-static method suite(char) cannot be referenced from a static context
          int st=suite(ch);
                 ^
karte.java:27: error: non-static method num(String) cannot be referenced from a static context
          int m=num(str.substring(i+1,i+3));
                ^
3 errors