惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
CXSECURITY Database RSS Feed - CXSecurity.com
K
Kaspersky official blog
A
Arctic Wolf
Attack and Defense Labs
Attack and Defense Labs
L
LINUX DO - 热门话题
N
News | PayPal Newsroom
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
L
Lohrmann on Cybersecurity
PCI Perspectives
PCI Perspectives
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
The Last Watchdog
The Last Watchdog
B
Blog RSS Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
W
WeLiveSecurity
Know Your Adversary
Know Your Adversary
博客园 - Franky
T
Tenable Blog
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Help Net Security
Help Net Security
WordPress大学
WordPress大学
T
The Exploit Database - CXSecurity.com
www.infosecurity-magazine.com
www.infosecurity-magazine.com
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
D
Darknet – Hacking Tools, Hacker News & Cyber Security
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
S
Security Affairs
J
Java Code Geeks
小众软件
小众软件
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Apple Machine Learning Research
Apple Machine Learning Research
NISL@THU
NISL@THU
O
OpenAI News
The Cloudflare Blog
月光博客
月光博客
Google Online Security Blog
Google Online Security Blog
V
V2EX
罗磊的独立博客
美团技术团队
博客园 - 三生石上(FineUI控件)
Security Latest
Security Latest
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
Cyber Attacks, Cyber Crime and Cyber Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cyberwarzone
Cyberwarzone
L
LINUX DO - 最新话题
Hacker News - Newest:
Hacker News - Newest: "LLM"
大猫的无限游戏
大猫的无限游戏

博客园 - 我的bug

项目引入同一jar包不同版本处理 【笔记】redis实现类 【笔记】websockt一对一聊天java部分 【笔记】vue中websocket心跳机制 【笔记】MySQL删除重复记录保留一条 oss上传实例 jquery实现图片点击旋转 IDEA卡顿解决方法 斐波那契数列 【笔记】接口发送数据及接收 【笔记】获取新浪财经最新的USDT-CNY的汇率 【笔记】Java 信任所有SSL证书(解决PKIX path building failed问题) 【笔记】jquery判断两个日期之间相差多少天 【笔记】spring定时器时间配置实例 【笔记】jquery加减乘除及科学计算法处理 string 日期相加和相减 sql查询慢原因及优化 找出一组数字中出现最多的字符 【转载】js清空cookie
java小算法复习
我的bug · 2017-06-20 · via 博客园 - 我的bug

package com.bshinfo.bm.util;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;

public class Test {

//菱形
public void test1(){
for (int i = 0; i < 5; i++) {//行数
for (int j = 0; j <5-i-1; j++) {//空格
System.out.print(" ");
}
for (int k = 0; k < 2*(i+1)-1; k++) {//星号
System.out.print("*");
}
System.out.println("");
}
for (int i = 5; i > 0; i--) {//行数
for (int j =5-i+1; j >0; j--) {//空格
System.out.print(" ");
}
for (int k = 2*(i-1)-1; k >0; k--) {//星号
System.out.print("*");
}
System.out.println("");
}
}
//菱形
public void test2(int n){
for(int i = 0; i < n - 1; i++){
for(int x = i + 1; x < n; x++){
System.out.print(" ");
}
for(int y = 0; y < (i + 1) * 2 - 1; y++){
System.out.print("*");
}
System.out.println();
}
for(int i = 0; i < n; i++){
for(int x = 0; x < i; x++){
System.out.print(" ");
}
for(int y = i; y < 2 * n - i - 1; y++){
System.out.print("*");
}
System.out.println();
}
}

//三角形
public void test3(){
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5-i-1; j++) {
System.out.print(" ");
}
for (int j = 0; j < i+1; j++) {
System.out.print("*");
}
System.out.println("");
}
}

//九九乘法表
public void test4(){

for (int i = 1; i < 10; i++) {
for (int j = 1; j < i+1; j++) {
System.out.print(j+"*"+i+"="+(i*j)+" ");
}
System.out.println("");
}
}
//统计字符串中字符出现的个数
public void test5(){
String str = "asdfsadfewrtewfxzfagres";
Map<String,Integer> map =new HashMap<String,Integer>();
int count = str.length();
for (int i = 0; i < count; i++) {
if(map.containsKey(str.substring(i, i+1))){
int temp = map.get(str.substring(i, i+1));
temp++;
map.put(str.substring(i, i+1), temp);
}else{
map.put(str.substring(i, i+1),1);
}
}
for (String key:map.keySet()) {
int value = map.get(key);
System.out.println("字符 "+key+" 出现的次数是"+value);
}
}
//判断是否输入的是水仙花数
public void test6(){
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
int count = str.length();
if(count%2!=0){
int temp = 0;
for (int i = 0; i < count/2; i++) {
int temp1 = Integer.parseInt(str.substring(i, i+1));
int temp2 = Integer.parseInt(str.substring(count-i-1, count-i));
if(temp1!=temp2){
System.out.println(str +" 不是水仙花数!");
return;
}else{
temp++;
}
}
if(temp == (count/2)){
System.out.println(str +" 是水仙花数!");
}
}

}
public static void main(String[] args) {

Test test = new Test();
test.test1();
test.test2(5);
test.test3();
test.test4();
test.test5();
test.test6();
}

}