字符串减法、ACSII码
AC代码:
普通代码:
import javax.swing.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.nio.file.attribute.AclEntryFlag;
import java.security.AlgorithmConstraints;
import java.sql.Struct;
import java.text.CollationElementIterator;
import java.text.DateFormatSymbols;
import java.util.*;
import java.util.stream.Collectors;public class Main
{static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));static int N = (int)2e5 + 10;static math_myself math_me = new math_myself();static int a[] = new int[N];public static void main(String[] args ) throws IOException{char a[] = rd.nextLine().toCharArray();char b[] = rd.nextLine().toCharArray();StringBuilder s = new StringBuilder("");// 将b数组的字符的ascii码都变成1,打个标记int ascii[] = new int [N];for(int i = 0 ; i < b.length ; i ++){ascii[b[i]] = 1;}// 将ascii码不为1的字符输出,即为A-B的结果for(int i = 0 ; i < a.length ; i ++){if(ascii[a[i]] == 1) continue;else pw.print(a[i]);}pw.println(s);pw.flush();}
}class rd
{static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));static StringTokenizer tokenizer = new StringTokenizer("");static String nextLine() throws IOException { return reader.readLine(); }static String next() throws IOException{while (!tokenizer.hasMoreTokens()) tokenizer = new StringTokenizer(reader.readLine());return tokenizer.nextToken();}static int nextInt() throws IOException { return Integer.parseInt(next()); }static double nextDouble() throws IOException { return Double.parseDouble(next()); }static long nextLong() throws IOException { return Long.parseLong(next());}static BigInteger nextBigInteger() throws IOException{BigInteger d = new BigInteger(rd.nextLine());return d;}
}class PII
{int x,y;public PII(int x ,int y){this.x = x;this.y = y;}
}class math_myself
{int gcd(int a,int b){if(b == 0) return a;else return gcd(b,a % b);}int lcm(int a,int b){return a * b / gcd(a, b);}// 求n的所有约数List get_factor(int n){List<Long> a = new ArrayList<>();for(long i = 1; i <= Math.sqrt(n) ; i ++){if(n % i == 0){a.add(i);if(i != n / i) a.add(n / i); // // 避免一下的情况:x = 16时,i = 4 ,x / i = 4的情况,这样会加入两种情况 ^-^复杂度能减少多少是多少}}// 相同因子去重,这个方法,完美a = a.stream().distinct().collect(Collectors.toList());// 对因子排序(升序)Collections.sort(a);return a;}// 判断是否是质数boolean check_isPrime(int n){if(n < 2) return false;for(int i = 2 ; i <= n / i; i ++) if (n % i == 0) return false;return true;}
}
加了StringBuilder的代码:(将A和B中不重叠的字符加到一个新的StringBuilder里面去)
import javax.swing.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.nio.file.attribute.AclEntryFlag;
import java.security.AlgorithmConstraints;
import java.sql.Struct;
import java.text.CollationElementIterator;
import java.text.DateFormatSymbols;
import java.util.*;
import java.util.stream.Collectors;public class Main
{static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));static int N = (int)2e5 + 10;static math_myself math_me = new math_myself();static int a[] = new int[N];public static void main(String[] args ) throws IOException{char a[] = rd.nextLine().toCharArray();char b[] = rd.nextLine().toCharArray();StringBuilder s = new StringBuilder("");// 将b数组的字符的ascii码都变成1,打个标记int ascii[] = new int [N];for(int i = 0 ; i < b.length ; i ++){ascii[b[i]] = 1;}// 将ascii码不为1的字符输出,即为A-B的结果for(int i = 0 ; i < a.length ; i ++){if(ascii[a[i]] == 1) continue;else s.append(a[i]);}pw.println(s);pw.flush();}
}class rd
{static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));static StringTokenizer tokenizer = new StringTokenizer("");static String nextLine() throws IOException { return reader.readLine(); }static String next() throws IOException{while (!tokenizer.hasMoreTokens()) tokenizer = new StringTokenizer(reader.readLine());return tokenizer.nextToken();}static int nextInt() throws IOException { return Integer.parseInt(next()); }static double nextDouble() throws IOException { return Double.parseDouble(next()); }static long nextLong() throws IOException { return Long.parseLong(next());}static BigInteger nextBigInteger() throws IOException{BigInteger d = new BigInteger(rd.nextLine());return d;}
}class PII
{int x,y;public PII(int x ,int y){this.x = x;this.y = y;}
}class math_myself
{int gcd(int a,int b){if(b == 0) return a;else return gcd(b,a % b);}int lcm(int a,int b){return a * b / gcd(a, b);}// 求n的所有约数List get_factor(int n){List<Long> a = new ArrayList<>();for(long i = 1; i <= Math.sqrt(n) ; i ++){if(n % i == 0){a.add(i);if(i != n / i) a.add(n / i); // // 避免一下的情况:x = 16时,i = 4 ,x / i = 4的情况,这样会加入两种情况 ^-^复杂度能减少多少是多少}}// 相同因子去重,这个方法,完美a = a.stream().distinct().collect(Collectors.toList());// 对因子排序(升序)Collections.sort(a);return a;}// 判断是否是质数boolean check_isPrime(int n){if(n < 2) return false;for(int i = 2 ; i <= n / i; i ++) if (n % i == 0) return false;return true;}
}
字符串减法、ACSII码相关推荐
- C#字符串转换为Acsii码,Ascii转化为字符串
1,现在因为遇到一个读取pdf文件文本信息遇到乱么问题,才找到这个文本字符串的编码转换的实现方式来判断是否存在乱码(0>乱码>255): C# 字符转ASCII码,ASCII码转字符 pu ...
- python 语言, 详解fromstring 函数 -------------从字符串到Ascii 码的转换
先来个小例子: test = "abcdef" temp = numpy.fromstring(test,dtype=numpy.int8) print(temp) 结果为:[ 9 ...
- 输入一个字符串,用子函数完成在字符串中找出ACSII码值最大的字符,将其放在第一个位置,并将该字符前的所有字符向后顺序移动
<程序设计基础实训指导教程-c语言> ISBN 978-7-03-032846-5 p143 7.1.2 上级实训内容 [实训内容9]输入一个字符串,用子函数完成在字符串中找出ACSII码 ...
- C语言小算法:ACSII码(多字节)和Unicode(宽字节)互转
C语言小算法:ACSII码(多字节)和Unicode(宽字节)互转 代码: #include <Windows.h> #include <stdio.h> #include & ...
- MATLAB字符串和ASCII码的转换
字符串转ASCII码:abs,如:abs('a');abs('what'); ASCII码转字符串:char,如:char(97);char([97,98,99]);
- 字符串固定长度 易语言_易语言字符串操作源码
易语言字符串操作源码 系统结构:字符串_取长度,字符串_取中间,字符串_取左边,字符串_取右边,字符串_替换,到宽字符,到多字节,取文本数据地址,取字节集数据地址,MultiByteToWideCha ...
- Ruby 对字符串进行转码
Ruby 对字符串进行转码 require 'iconv' input_encoding = "windows-1252" output_encoding = 'utf-8' co ...
- python 字符串与ASCII码转换的脚本
这里写自定义目录标题 #!/usr/bin/python coding=utf-8flag = 1 while flag:print(">>=================== ...
- python字符串按ascii码排序_C# 字符串按 ASCII码 排序的方法
在和银行做数据对接时,涉及到数据传输时的验签及加密.其中数据签名方案中就要求数据项根据属性名按 ASCII码 进行升序排序.C#中的ASCII码排序并不是表面上那么简单,一不小心就入坑了.因为C#的排 ...
- Redis源码-String:Redis String命令、Redis String存储原理、Redis String三种编码类型、Redis字符串SDS源码解析、Redis String应用场景
Redis源码-String:Redis String命令.Redis String存储原理.Redis String三种编码类型.Redis字符串SDS源码解析.Redis String应用场景 R ...
最新文章
- 全球首个软硬件推理平台 :NVDLA编译器正式开源
- Android中获取当前位置的使用步骤
- 1 计算机主机里面都有些什么东西,计算机主机和外设分别包括那些东西?
- 学习 AngularJs 终于有点进步了。
- mybatis plus实现多表分页条件查询
- Win Form中限制TextBox只能输入数字
- SecureCRT 超级终端 不能输入命令
- matlab3阶幺矩阵,Matlab操作矩阵的相关方法
- 股票预测pythonlstm_LSTM预测股票涨跌--结合技术分析视角(一)
- CVPR2021 MotionRNN: A Flexible Model for Video Prediction with Spacetime-Varying Motions
- 丢失LDF文件怎么办?
- IDEA报错private field “xxx“ is never assigned解决
- 磁盘盘符隐藏并访问隐藏磁盘的文件数据
- Jmeter 安装历史版本
- makefile超级详解
- 使用JQuery快速高效制作网页交互特效第五章所有上机
- TensorRT5.1.6加速PReLU
- Vector - VT System - 板卡_VT8006/VT8012
- WS-DAN:Weakly Supervised Data Augmentation Netowrk for Fine-Grained Visual Classification
- CAD怎么转PDF?手把手教你转换
热门文章
- 再谈用Excel计算年龄
- 一些在线文档协助软件收集
- 计算机组成原理课程作业,兰大网院17春计算机组成原理课程作业 C.doc
- vue es6转es5 保证浏览器兼容性
- FTP工作原理及内网用端口映射方式建FTP的注意事项
- 微信小程序wxs文件,(indexOf方法)
- CString头文件怎么用?
- iar使用秉火DAP仿真时出现错误 Download error at 0x08000000: downloading into non-writable memory.
- RT-Thread学习笔记
- GO语言的实战学习(猜谜游戏和在线词典)| 青训营笔记