728x90
SMALL

using System;

public class Solution {
    public string solution(string[] id_pw, string[,] db) {
        string answer = "";
        
        for(int i = 0; i < db.GetLength(0); i++)
        {
            if(id_pw[0] == db[i,0])
            {
                if(id_pw[1] == db[i,1])
                {
                    answer = "login";
                }
                else
                {
                    answer = "wrong pw";
                }
                break;
            }
            else
            {
                answer = "fail";
            }
        }
        return answer;
    }
}

 

 

자바

 

 

class Solution {
    public String solution(String[] id_pw, String[][] db) {
        String answer = "";

        for(int i = 0; i < db.length; i++)
        {
            if(db[i][0].equals(id_pw[0]))
            {
                if(db[i][1].equals(id_pw[1]))
                {
                    return "login";
                }
                
                return "wrong pw";
            }
        }
        
        return "fail";
    }
}

 

 

class Solution {
    public String solution(String[] id_pw, String[][] db) {
        String id = id_pw[0];
        
        for(String[] user : db)
        {
            if(id.equals(user[0]))
            {
                if(id_pw[1].equals(user[1])) return "login";
                return "wrong pw";
            }
        }
        
        return "fail";
    }
}
728x90

설정

트랙백

댓글