답안 #584213

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
584213 2022-06-27T04:11:55 Z Shubham_4070 Karte (COCI15_karte) Java 11
컴파일 오류
0 ms 0 KB
import java.util.*;

static  int suite(char ch){
    if(ch=='P')return 0;
    if(ch=='K')return 1;
     if(ch=='H')return 2;
    return 3;
  }
  static 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:3: error: class, interface, or enum expected
static  int suite(char ch){
        ^
karte.java:5: error: class, interface, or enum expected
    if(ch=='K')return 1;
    ^
karte.java:6: error: class, interface, or enum expected
     if(ch=='H')return 2;
     ^
karte.java:7: error: class, interface, or enum expected
    return 3;
    ^
karte.java:8: error: class, interface, or enum expected
  }
  ^
karte.java:11: error: class, interface, or enum expected
    for(int i=0;i<=1;i++)
    ^
karte.java:11: error: class, interface, or enum expected
    for(int i=0;i<=1;i++)
                ^
karte.java:11: error: class, interface, or enum expected
    for(int i=0;i<=1;i++)
                     ^
karte.java:14: error: class, interface, or enum expected
       res=res*10+(ch-'0');   
       ^
karte.java:15: error: class, interface, or enum expected
    }
    ^
karte.java:17: error: class, interface, or enum expected
  }
  ^
karte.java:18: error: class, interface, or enum expected
	public static void main(String[] args) {
	              ^
karte.java:20: error: class, interface, or enum expected
       String str=ob.next();
       ^
karte.java:21: error: class, interface, or enum expected
      int vis[][]=new int[4][14];
      ^
karte.java:22: error: class, interface, or enum expected
      int n=str.length();
      ^
karte.java:23: error: class, interface, or enum expected
        for(int i=0;i<n;i+=3){
        ^
karte.java:23: error: class, interface, or enum expected
        for(int i=0;i<n;i+=3){
                    ^
karte.java:23: error: class, interface, or enum expected
        for(int i=0;i<n;i+=3){
                        ^
karte.java:25: error: class, interface, or enum expected
          int st=suite(ch);
          ^
karte.java:26: error: class, interface, or enum expected
          int m=num(str.substring(i+1,i+3));
          ^
karte.java:27: error: class, interface, or enum expected
          if(vis[st][m]==1)
          ^
karte.java:30: error: class, interface, or enum expected
            return;
            ^
karte.java:31: error: class, interface, or enum expected
          }
          ^
karte.java:34: error: class, interface, or enum expected
           }
           ^
karte.java:37: error: class, interface, or enum expected
      for(int i=0;i<=3;i++){
      ^
karte.java:37: error: class, interface, or enum expected
      for(int i=0;i<=3;i++){
                  ^
karte.java:37: error: class, interface, or enum expected
      for(int i=0;i<=3;i++){
                       ^
karte.java:39: error: class, interface, or enum expected
        for(int j=1;j<=13;j++){
        ^
karte.java:39: error: class, interface, or enum expected
        for(int j=1;j<=13;j++){
                    ^
karte.java:39: error: class, interface, or enum expected
        for(int j=1;j<=13;j++){
                          ^
karte.java:41: error: class, interface, or enum expected
        }
        ^
karte.java:44: error: class, interface, or enum expected
      for(int i=0;i<ans.length;i++){
                  ^
karte.java:44: error: class, interface, or enum expected
      for(int i=0;i<ans.length;i++){
                               ^
karte.java:46: error: class, interface, or enum expected
      }
      ^
34 errors