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码相关推荐

  1. C#字符串转换为Acsii码,Ascii转化为字符串

    1,现在因为遇到一个读取pdf文件文本信息遇到乱么问题,才找到这个文本字符串的编码转换的实现方式来判断是否存在乱码(0>乱码>255): C# 字符转ASCII码,ASCII码转字符 pu ...

  2. python 语言, 详解fromstring 函数 -------------从字符串到Ascii 码的转换

    先来个小例子: test = "abcdef" temp = numpy.fromstring(test,dtype=numpy.int8) print(temp) 结果为:[ 9 ...

  3. 输入一个字符串,用子函数完成在字符串中找出ACSII码值最大的字符,将其放在第一个位置,并将该字符前的所有字符向后顺序移动

    <程序设计基础实训指导教程-c语言> ISBN 978-7-03-032846-5 p143 7.1.2 上级实训内容 [实训内容9]输入一个字符串,用子函数完成在字符串中找出ACSII码 ...

  4. C语言小算法:ACSII码(多字节)和Unicode(宽字节)互转

    C语言小算法:ACSII码(多字节)和Unicode(宽字节)互转 代码: #include <Windows.h> #include <stdio.h> #include & ...

  5. MATLAB字符串和ASCII码的转换

    字符串转ASCII码:abs,如:abs('a');abs('what'); ASCII码转字符串:char,如:char(97);char([97,98,99]);

  6. 字符串固定长度 易语言_易语言字符串操作源码

    易语言字符串操作源码 系统结构:字符串_取长度,字符串_取中间,字符串_取左边,字符串_取右边,字符串_替换,到宽字符,到多字节,取文本数据地址,取字节集数据地址,MultiByteToWideCha ...

  7. Ruby 对字符串进行转码

    Ruby 对字符串进行转码 require 'iconv' input_encoding = "windows-1252" output_encoding = 'utf-8' co ...

  8. python 字符串与ASCII码转换的脚本

    这里写自定义目录标题 #!/usr/bin/python coding=utf-8flag = 1 while flag:print(">>=================== ...

  9. python字符串按ascii码排序_C# 字符串按 ASCII码 排序的方法

    在和银行做数据对接时,涉及到数据传输时的验签及加密.其中数据签名方案中就要求数据项根据属性名按 ASCII码 进行升序排序.C#中的ASCII码排序并不是表面上那么简单,一不小心就入坑了.因为C#的排 ...

  10. 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 ...

最新文章

  1. 对h.264压缩视频码流中i帧的提取(firstime)
  2. 熟悉MyEclipse
  3. 云图说|初识ModelArts开发者生态社区——AI Gallery
  4. csharp语言_电脑绝技教你22天学精Csharp之第五天
  5. 微信小程序做留言板mysql_微信小程序实现留言板(Storage)
  6. 现代操作系统(原书第四版)课后题答案 —— 第二章 进程与线程
  7. mysql复制表结构并创建新表_mysql ---复制表结构---创建新表
  8. 【CVPR2022】论文列表与下载——PartThree
  9. 【中国数据创新琅琊榜】萨纳斯大数据实验室,高校大数据教学、实训、人才培养的最佳选择!
  10. 太强!拿下腾讯公司技术突破奖,腾讯云 RTC 实时音视频技术到底了有多牛?...
  11. Mac下的平铺式桌面 - Yabai
  12. 在VS2017中添加WTL窗口
  13. 用Interl 5100AGN 无线网卡破解无线网络WEP密码
  14. 微信小程序 - “本地资源图片无法通过WXSS 获取,可以使用网络图片,或者 base64,或者使用标签” 解决
  15. Bulma的简单使用
  16. 20个必不可少的Python库也是基本的第三方库
  17. 递归、迭代和分治(1):递归
  18. Excel如何快速小计求和
  19. 区块链技术如何赋能医学成像?
  20. zookeeper zkCli.sh的基本使用方法

热门文章

  1. Unity Shader 阴影系列(2)--内置阴影源码解析
  2. Kinect2.0远程控制鼠标操作
  3. 全国计算机二级aoa真题题库,计算机AOA试题单选判断及答案.docx
  4. 如何进行MQ技术选型
  5. 求一个数的所有因数的和
  6. php解密方法,六种php加密解密方法实例讲解
  7. 以太网帧格式与交换机原理
  8. Ubuntu-vim的使用
  9. C2P工业云签署,实现无纸化,提高投资回报率
  10. docker安装HA