博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
kotlin 取整数_Kotlin程序连接两个整数数组
阅读量:2534 次
发布时间:2019-05-11

本文共 2240 字,大约阅读时间需要 7 分钟。

kotlin 取整数

Given two integer arrays, we have to concatenate them.

给定两个整数数组,我们必须将它们连接起来。

Example:

例:

Input:    arr1 = [10, 20, 30]    arr2 = [40, 50]    Output:    Concatenated array: [10, 20, 30, 40, 50]

程序在Kotlin中连接两个整数数组 (Program to concatenate two integer arrays in Kotlin)

package com.includehelp.basicimport java.util.*//Main Function entry Point of Programfun main(args: Array
) { //Input Stream val s = Scanner(System.`in`) //Input Array Size print("Enter number of elements in the array1: ") var size = s.nextInt() //Create Integer array of Given size val intArray1 = IntArray(size) //Input array elements println("Enter Arrays Elements:") for (i in intArray1.indices) { print("intArray1[$i] : ") intArray1[i] = s.nextInt() } //Input Array Size print("Enter number of elements in the array2: ") size = s.nextInt() //Create Integer array of Given size val intArray2 = IntArray(size) //Input array elements println("Enter Arrays Elements:") for (i in intArray2.indices) { print("intArray2[$i] : ") intArray2[i] = s.nextInt() } //Print Array1 Elements println("Array1 : ${intArray1.contentToString()}") //Print Array2 Elements println("Array2 : ${intArray2.contentToString()}") var concatArray = intArray1+intArray2 //Print concatArray Elements and its Size println("concatArray Elements : ${concatArray.contentToString()}") println("concatArray Size : ${concatArray.size}")}

Output

输出量

Run 1:-----Enter number of elements in the array1: 5Enter Arrays Elements:intArray1[0] : 3intArray1[1] : 4intArray1[2] : 5intArray1[3] : 6intArray1[4] : 798Enter number of elements in the array2: 3Enter Arrays Elements:intArray2[0] : 2intArray2[1] : 1intArray2[2] : 9Array1 : [3, 4, 5, 6, 798]Array2 : [2, 1, 9]concatArray Elements : [3, 4, 5, 6, 798, 2, 1, 9]concatArray Size     : 8--------Run 2:----Enter number of elements in the array1: 2Enter Arrays Elements:intArray1[0] : 6intArray1[1] : 5Enter number of elements in the array2: 3Enter Arrays Elements:intArray2[0] : 5intArray2[1] : 3intArray2[2] : 2Array1 : [6, 5]Array2 : [5, 3, 2]concatArray Elements : [6, 5, 5, 3, 2]concatArray Size     : 5

翻译自:

kotlin 取整数

转载地址:http://ezozd.baihongyu.com/

你可能感兴趣的文章
CTP2交易所成交回报
查看>>
WebSocket & websockets
查看>>
openssl 升级
查看>>
ASP.NET MVC:通过 FileResult 向 浏览器 发送文件
查看>>
CVE-2010-2883Adobe Reader和Acrobat CoolType.dll栈缓冲区溢出漏洞分析
查看>>
使用正确的姿势跨域
查看>>
AccountManager教程
查看>>
Android学习笔记(十一)——从意图返回结果
查看>>
算法导论笔记(四)算法分析常用符号
查看>>
ultraedit激活
查看>>
总结(6)--- python基础知识点小结(细全)
查看>>
亿级曝光品牌视频的幕后设定
查看>>
ARPA
查看>>
JSP开发模式
查看>>
我的Android进阶之旅------>Android嵌入图像InsetDrawable的使用方法
查看>>
Detours信息泄漏漏洞
查看>>
win32使用拖放文件
查看>>
Android 动态显示和隐藏软键盘
查看>>
raid5什么意思?怎样做raid5?raid5 几块硬盘?
查看>>
【转】how can i build fast
查看>>