Created
January 10, 2020 11:20
-
-
Save anirudh708/6c069cd48077d22f2eca5ae258531c92 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class One { | |
public static void main(String[] args) { | |
int A = 2, B = 5; | |
int a = 1, b = 1; String result = ""; | |
while ((A+B)>0) { | |
if (A > B) { | |
if (a < 3) { | |
result += "a"; | |
a++; b=1; A--; | |
} else { | |
result += "b"; | |
b++; a=1; b--; | |
} | |
} else { | |
if (b < 3) { | |
result += "b"; | |
b++; a=1; B--; | |
} else { | |
result += "a"; | |
a++; b=1; A--; | |
} | |
} | |
} | |
System.out.println(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment