PAT (Basic Level) Practise (中文) 1056. 组合数的和(15)
2017-09-12 21:47
483 查看
1056. 组合数的和(15)
时间限制400 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
CHEN, Yue
给定N个非0的个位数字,用其中任意2个数字都可以组合成1个2位的数字。要求所有可能组合出来的2位数字的和。例如给定2、5、8,则可以组合出:25、28、52、58、82、85,它们的和为330。
输入格式:
输入在一行中先给出N(1<N<10),随后是N个不同的非0个位数字。数字间以空格分隔。
输出格式:
输出所有可能组合出来的2位数字的和。
输入样例:
3 2 8 5
输出样例:
330
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input=new Scanner(System.in); int n=input.nextInt(); int arr[]=new int ; for (int i = 0; i < arr.length; i++) { arr[i]=input.nextInt(); } int sum=0; for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr.length; j++) { if (i!=j) { //int temp=Integer.parseInt(arr[i]+""+arr[j]); sum+=Integer.parseInt(arr[i]+""+arr[j]); } } // for (int j = arr.length-1; j > 0; j--) { // sum+=Integer.parseInt(arr[j]+""+arr[i]); // } } System.out.println(sum); } }
相关文章推荐
- PAT (Basic Level) Practise (中文)1056. 组合数的和(15)
- PAT (Basic Level) Practise (中文) 1036. 跟奥巴马一起编程(15)
- PAT (Basic Level) Practise (中文) 1046. 划拳(15)
- PAT (Basic Level) Practise (中文)-1031. 查验身份证(15)
- PAT (Basic Level) Practise (中文)- 1016. 部分A+B (15)
- PAT (Basic Level) Practise (中文)- 1006. 换个格式输出整数 (15)
- PAT (Basic Level) Practise (中文)1001. 害死人不偿命的(3n+1)猜想 (15)
- PAT (Basic Level) Practise (中文)1011. A+B和C (15) C语言
- PAT (Basic Level) Practise (中文)1026. 程序运行时间(15) C语言
- PAT (Basic Level) Practise (中文)1031. 查验身份证(15)
- PAT (Basic Level) Practise (中文)1051. 复数乘法 (15)
- PAT (Basic Level) Practise (中文)1021. 个位数统计 (15)
- PAT (Basic Level) Practise (中文)1041. 考试座位号(15)
- PAT (Basic Level) Practise (中文)1001害死人不偿命的(3n+1)猜想(15)
- PAT (Basic Level) Practise (中文) 1016. 部分A+B (15)
- PAT (Basic Level) Practise (中文) 1026. 程序运行时间(15)
- PAT (Basic Level) Practise (中文)1041. 考试座位号(15) C语言
- PAT (Basic Level) Practise (中文)1036. 跟奥巴马一起编程(15)
- PAT (Basic Level) Practise (中文) 1061. 判断题(15)
- PAT (Basic Level) Practise (中文) 1006. 换个格式输出整数 (15)