当前位置:网站首页>Sum of two numbers, the numbers in the array are converted to decimal, added, and output inversely
Sum of two numbers, the numbers in the array are converted to decimal, added, and output inversely
2022-07-05 06:36:00 【Said it was all】
public class Sum of two numbers {
public static void main(String[] args) {
Sum of two numbers t=new Sum of two numbers ();
System.out.println(" Enter the first array , Whitespace separated ");
int arr1[]=t.arr();
int sum1=0;
int sum2=0;
for(int i=0;i<arr1.length;i++){
sum1 = sum1+(int) (arr1[i]*(Math.pow(10,arr1.length-(i+1))));
}
System.out.println(" Enter the second array , Whitespace separated ");
int arr2[]=t.arr();
for ( int i=0;i<arr2.length;i++){
sum2 = sum2+(int) (arr2[i]*(Math.pow(10,arr1.length-(i+1))));
}
int sum=sum1+sum2;
String ssum=String.valueOf(sum);
String sumarry[] = ssum.split("");
for(int i=0;i<sumarry.length;i++){
if(i==sumarry.length-(i+1)) break; // Odd critical condition
if(i>sumarry.length-(i+1)) break; // Even critical condition
String c=sumarry[sumarry.length-(i+1)];
sumarry[sumarry.length-(i+1)] =sumarry[i];
sumarry[i]=c;
}
for (String a:sumarry){
System.out.print(a);
}
}
public int[] arr (){
Scanner sc = new Scanner(System.in);
String inputString = sc.nextLine();
String stringArray[] = inputString.split(" ");
int intarr[]=new int[stringArray.length];
for (int i=0;i<stringArray.length;i++){
intarr[i]=Integer.parseInt(stringArray[i]);
}
return intarr;
}
}
Example :
Similar to the second question of Li Kou , But there is no linked list here .
边栏推荐
- [Gaode map POI stepping pit] amap Placesearch cannot be used
- 如何正确在CSDN问答进行提问
- SQL三种连接:内连接、外连接、交叉连接
- [BMZCTF-pwn] ectf-2014 seddit
- 'mongoexport 'is not an internal or external command, nor is it a runnable program or batch file.
- SolidWorks template and design library are convenient for designers to call
- Genesis builds a new generation of credit system
- Game theory acwing 894 Split Nim game
- Chinese remainder theorem acwing 204 Strange way of expressing integers
- [2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields
猜你喜欢

5.Oracle-表空间

4.Oracle-重做日志文件管理

Operator priority, one catch, no doubt

求组合数 AcWing 888. 求组合数 IV
![[wustctf2020] plain_ WP](/img/66/fdf7649359f36444703ff2279562e6.jpg)
[wustctf2020] plain_ WP

Bash exercise 17 writing scripts to install the server side of FRP reverse proxy software
![[2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields](/img/65/7fa32cd0005ddaaebacd85c25e0c7e.jpg)
[2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields

Sorting out the latest Android interview points in 2022 to help you easily win the offer - attached is the summary of Android intermediate and advanced interview questions in 2022

7. Oracle table structure

AE tutorial - path growth animation
随机推荐
Find the combination number acwing 887 Find combination number III
TypeScript入门
Find the combination number acwing 888 Find the combination number IV
[QT] QT multithreading development qthread
Applicable to Net free barcode API [off] - free barcode API for NET [closed]
代码中的英语全部
容斥原理 AcWing 890. 能被整除的数
Knapsack problem acwing 9 Group knapsack problem
LSA Type Explanation - detailed explanation of lsa-2 (type II LSA network LSA) and lsa-3 (type III LSA network Summary LSA)
[2021]IBRNet: Learning Multi-View Image-Based Rendering Qianqian
FFmpeg build下载(包含old version)
Nested method, calculation attribute is not applicable, use methods
June 29, 2022 daily
[wustctf2020] plain_ WP
5. Oracle tablespace
【高德地图POI踩坑】AMap.PlaceSearch无法使用
Day 2 document
Vant Weapp SwipeCell設置多個按鈕
RecyclerView的应用
[Chongqing Guangdong education] 1185t administrative leadership reference test of National Open University in autumn 2018