Posts

Showing posts from September 10, 2022

White

 class Three{ public static void main(String []  gdv){ String input1="999"; String input2="99"; int len1=input1.length(); int len2=input2.length(); int len=(len1>len2) ?len1:len2; len=len+1; int lenl=len; char []ch=new char[len]; int sum=0; int val=0; for(int i=0;i<lenl;i++){ if(i<len1&&i<len2){ val=(int)(input1.charAt(i)-48)+(input2.charAt(i)-48)+sum; if (val>9){ val%=10; sum=1; }else sum=0; ch[--len]=(char)(val+48); }else{ if(i>=len1) val=(int)(input2.charAt(i)-48+sum); else  if(i>=len2) val=(int)(input1.charAt(i)-48+sum); if (val>9){ val%=10; sum=1; } else sum=0; ch[--len]=(char)(val+48); } } System.out.println("\n"); for(char c:ch) System.out.print(c); System.out.println("\n"); System.out.println(len); } }