HW6.5

import java.util.Scanner;
public class Solution
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print("Enter 10 numbers: ");
int[] number1 = new int[10];
int[] number2 = new int[10];
for(int i = 0; i < 10; i++)
number1[i] = input.nextInt();
input.close();
for(int i = 0; i < 10; i++)
{
if(contain(number2, number1[i]))
continue;
add(number2, number1[i]);
}
System.out.print("The distinct numbers are: ");
for(int i: number2)
if(i != 0)
System.out.print(i + " ");
}
public static boolean contain(int[] array, int n)
{
for(int i: array)
if(i == n)
return true;
return false;
}
public static void add(int[] array, int n)
{
for(int i = 0; i < array.length; i++)
if(array[i] == 0)
{
array[i] = n;
break;
}
}
}
HW6.5的更多相关文章
- HW6.30
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW6.29
public class Solution { public static void main(String[] args) { int count = 0; int[] card = new int ...
- HW6.28
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW6.27
import java.util.Scanner; import java.util.Arrays; public class Solution { public static void main(S ...
- HW6.26
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW6.25
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW6.24
public class Solution { public static void main(String[] args) { int count = 0; int color; int numbe ...
- HW6.23
public class Solution { public static void main(String[] args) { boolean[] box = new boolean[101]; f ...
- HW6.22
import java.util.Arrays; public class Solution { public static void main(String[] args) { int[][] ch ...
- HW6.21
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
随机推荐
- 写给 iOS 开发者的 Hopper + lldb 简介
最近,关于 @Steipete 在Radar发布的帖子,笔者看到很多人在问「你是怎么理解那个伪代码的」.笔者想写博客已经有一段时间了,现在正好就此发表第一篇博文.笔者在一个叫 Hopper 的工具上花 ...
- JavaScript 踩坑心得— 为了高速(下)
一.前言 本文的上一篇 JavaScript 踩坑心得- 为了高速(上) 主要和大家分享的是 JavaScript 使用过程中的基本原则以及编写过程中的心得分享,本文主要和大家聊聊在各个使用场景下的 ...
- Executing a script from Nagios event handler fails to run
I have Nagios running on a webserver. For this one Nagios service check in particular, if it fails, ...
- 1028-Digital Roots
描述 The digital root of a positive integer is found by summing the digits of the integer. If the resu ...
- HDU 1757 A Simple Math Problem(矩阵快速幂)
题目链接 题意 :给你m和k, 让你求f(k)%m.如果k<10,f(k) = k,否则 f(k) = a0 * f(k-1) + a1 * f(k-2) + a2 * f(k-3) + …… ...
- linux 模拟延时和丢包
这是 RHCA 中的一个 BDP 的测试,这也是公司很常用的一种延时和丢包的模拟,现在分享给大家. 我们做的应用软件,还有测试 TCP/UDP 对比,测试 BDP 对 TCP/IP 的影响时,我们都 ...
- nginux做反向代理配置文件
做反向代理的配置文件最好单独创建一个文件,然后在主配置文件中使用 include nginx-test.config; 这样的方式来导入. 配置代码如下: ## Basic reverse prox ...
- HeadFirst设计模式之策略模式
什么是策略模式:它定义了一系列算法,可以根据不同的实现调用不同的算法 大多数的设计模式都是为了解决系统中变化部分的问题 一.OO基础 抽象.封装.多态.继承 二.OO原则 1.封装变化,如把FlyBe ...
- QPushButton 的checkable 属性
只有setCheckable(true),这个button才能发射 toggle(bool) 信号. 而toggle(bool)代表了button 按下,弹起的状态像0,1的切换开关.
- java去除重复的字符串和移除不想要的字符串
在java开发中碰到了有些字符串是重复的,如果在进行业务处理要全部遍历太对的数据就会重复,所以在进行业务处理前进行一个去重操作. 这里由于业务需要所以先将字符串转化为string数组,使用split分 ...