Monday, May 31, 2021

codeforces 45A Solution A. Codecraft lll (codeforces 45A) (rank 900*)

 45A. Codecraft lll


Problem Link: https://codeforces.com/problemset/problem/45/A


Solution 1:


import java.util.Scanner;

public class A45 {

    public static Scanner scn = new Scanner(System.in);

    public static String[] str = { "January""February""March""April""May""June""July""August",
            "September""October""November""December" };

    public static int nextIdx(int currIdxint change) {
        return (currIdx + change) % 12;
    }

    public static int currIdx(String myStr) {
        for (int i = 0i < str.lengthi++) {
            if (myStr.equals(str[i]))
                return i;
        }
        return -1;
    }

    public static void main(String[] argv) {

        String str2 = scn.next();
        int change = scn.nextInt();
        int idx = currIdx(str2);
        System.out.println(str[nextIdx(idxchange)]);
    }
}

No comments:

Post a Comment

Thanks

Climate Crisis and Innovation: Navigating Earth's Future

Climate Change: Recent Events and Technological Solutions 1. The Escalating Climate Crisis The climate crisis has intensified in recent year...