Get the App
SLTechnology News&Howtos  ›  Servers  › 

How does Java output two digits

Shulou Source: shulou.com Published: 2022-05-31 17:56:44 09月14日 Update

This article mainly introduces "how to output two digits from Java". In daily operation, I believe many people have doubts about how to output two digits from Java. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to output two digits by Java". Next, please follow the editor to study!

Given nums = [2,7,11,15], target = 9 com.lifeibigdata.algorithms.leetcode;/** nums [0] + nums [1] = 2 + 7 = 9 recorder return [0,1] .package com.lifeibigdata.algorithms.leetcode;/** * Created by lifei on 16-5-27. * * 1 * / public class TwoSum {public static void main (String [] args) {int [] nums = {0for (int I: res) {/ / System.out.printf (I + "); / /} twoSum2 (nums,20) } public int [] twoSum (int [] nums, int target) {int [] res = new int [2]; for (int I = 0; I

< nums.length; i++){ boolean flag = true; for (int j = 0;j < nums.length; j++){ if (i == j) continue; if (nums[i] + nums[j] == target){ res[0] = i; res[1] = j; flag = false; break; } } if (!flag) break; } return res; } static void twoSum2(int[] a,int sum){ int i = 0; int j = a.length - 1; while (i < j){ if (a[i] + a[j] < sum){ i++; } else if (a[i] + a[j] >

Sum) {jmurmurf;} else {System.out.println (a [I] + "- -" + a [j]); iTunes; jmurf;} this is the end of the study on "how to output two numbers from Java", hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Two numbers output learning more help practical next articles methods theories knowledge articles websites materials follow questions jacks easy to use practice Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology vpn Shulou Tech Info OPPO Reno Huawei