In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
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!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.