0
点赞
收藏
分享

微信扫一扫

2-8 JAVA [字符串的简单加密]

外贸达人小峻先森 2022-04-13 阅读 61
java

题目描述

大家c语言的学的第一个程序应该就是输出hello world,我们知道每一个字符都有一个ASCII码,比如输出

hello world每一个字符的ASCII码+1对应的那个字符.比如a对应ASCII码的下一个字符是b.

输入描述:

hello world

输出描述:

ifmmp!xpsme

参考代码:

import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String str=sc.nextLine();//这里如果是sc.next();就读不进空格了
		for(int i=0;i<str.length();i++) {
			System.out.print((char)(str.charAt(i)+1));
		}
	}
}

 

举报

相关推荐

0 条评论