当前位置:网站首页>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 .
边栏推荐
- Applicable to Net free barcode API [off] - free barcode API for NET [closed]
- Series of how MySQL works (VIII) 14 figures explain the atomicity of MySQL transactions and the principle of undo logging
- How to answer when you encounter a jet on CSDN?
- Alibaba's new member "Lingyang" officially appeared, led by Peng Xinyu, Alibaba's vice president, and assembled a number of core department technical teams
- How to make water ripple effect? This wave of water ripple effect pulls full of retro feeling
- 2021apmcm post game Summary - edge detection
- H5 embedded app adapts to dark mode
- How to correctly ask questions in CSDN Q & A
- Ffmpeg build download (including old version)
- 2048项目实现
猜你喜欢

安装OpenCV--conda建立虚拟环境并在jupyter中添加此环境的kernel

SQL三种连接:内连接、外连接、交叉连接
![[Gaode map POI stepping pit] amap Placesearch cannot be used](/img/4c/55586ffcc2267c477a4532ab51a0c1.png)
[Gaode map POI stepping pit] amap Placesearch cannot be used
![[algorithm post interview] interview questions of a small factory](/img/62/6e330b1eba38f2dc67b21a10f0e2a8.jpg)
[algorithm post interview] interview questions of a small factory
![[2020]GRAF: Generative Radiance Fields for 3D-Aware Image Synthesis](/img/20/826cc9d514496955a557439881234d.jpg)
[2020]GRAF: Generative Radiance Fields for 3D-Aware Image Synthesis

MPLS experiment

Gauss Cancellation acwing 884. Solution d'un système d'équations Xor linéaires par élimination gaussienne

什么是套接字?Socket基本介绍

2. Addition and management of Oracle data files

求组合数 AcWing 888. 求组合数 IV
随机推荐
Adg5412fbruz-rl7 applies dual power analog switch and multiplexer IC
将webApp或者H5页面打包成App
中国剩余定理 AcWing 204. 表达整数的奇怪方式
[Gaode map POI stepping pit] amap Placesearch cannot be used
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
Vscode configures the typera editor for MD
2022 winter vacation training game 5
Time is fast, please do more meaningful things
[learning] database: MySQL query conditions have functions that lead to index failure. Establish functional indexes
Chapter 6 relational database theory
C job interview - casting and comparing - C job interview - casting and comparing
Inclusion exclusion principle acwing 890 Divisible number
Utf8 encoding
5.Oracle-表空间
5.Oracle-錶空間
Knapsack problem acwing 9 Group knapsack problem
LeetCode-54
11-gorm-v2-03-basic query
[leetcode] day95 effective Sudoku & matrix zeroing
栈 AcWing 3302. 表达式求值