Java输入一批以问号“?”结束的字符,对“?”以前的每一个字符,如果它是大写字母,
答案:4 悬赏:30 手机版
解决时间 2021-03-27 20:11
- 提问者网友:雾里闻花香
- 2021-03-27 05:51
Java输入一批以问号“?”结束的字符,对“?”以前的每一个字符,如果它是大写字母,
最佳答案
- 五星知识达人网友:风格不统一
- 2021-03-27 06:40
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class Convert {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String strInput = "";
strInput = br.readLine();
int p = strInput.indexOf("?");
String temp = strInput.substring(0, p);
char[] char_array = temp.toCharArray();
for(int i=0;i if(char_array[i]<='z'&&char_array[i]>='a'){
char_array[i] = (char) (char_array[i]-32);
}
else if(char_array[i]<='Z'&&char_array[i]>='A'){
char_array[i] = (char) (char_array[i]+32);
}
}
temp = String.copyValueOf(char_array);
System.out.print(temp);
}
}
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class Convert {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String strInput = "";
strInput = br.readLine();
int p = strInput.indexOf("?");
String temp = strInput.substring(0, p);
char[] char_array = temp.toCharArray();
for(int i=0;i
char_array[i] = (char) (char_array[i]-32);
}
else if(char_array[i]<='Z'&&char_array[i]>='A'){
char_array[i] = (char) (char_array[i]+32);
}
}
temp = String.copyValueOf(char_array);
System.out.print(temp);
}
}
全部回答
- 1楼网友:舊物识亽
- 2021-03-27 08:33
我知道,但是现在懒得告诉你了
再骂我几句吧
再骂我几句吧
- 2楼网友:纵马山川剑自提
- 2021-03-27 07:22
import java.util.*;
public class Test {
public static void main(String[] args) {
System.out.println("输入字符串:");
Scanner read = new Scanner(System.in);
String str = read.nextLine();
char[] c = str.toCharArray();
change(c);
for(int i=0; i if(c[i]=='?') {
break;
}
System.out.print(c[i] + " ");
}
}
public static void change(char[] c) {
for(int i=0; i if(c[i]>'a' && c[i]<'z') {
c[i] =(char) (c[i] - 32);
} else if(c[i]>'A' && c[i]<'Z') {
c[i] =(char) (c[i] + 32);
}
}
}
}
public class Test {
public static void main(String[] args) {
System.out.println("输入字符串:");
Scanner read = new Scanner(System.in);
String str = read.nextLine();
char[] c = str.toCharArray();
change(c);
for(int i=0; i
break;
}
System.out.print(c[i] + " ");
}
}
public static void change(char[] c) {
for(int i=0; i
c[i] =(char) (c[i] - 32);
} else if(c[i]>'A' && c[i]<'Z') {
c[i] =(char) (c[i] + 32);
}
}
}
}
- 3楼网友:第幾種人
- 2021-03-27 07:04
haofuza
look!
import java.io.*;
public class Test30007 {
public static void main(String[] args)throws IOException{
char ch;
ch=(char)System.in.read();
while(ch!='?'){
if(ch>'a'&&ch<'z')
ch=(char) ( ch+'A'-'a');
else if(ch>'A'&&ch<'Z')
ch=(char) (ch+'a'-'A');
System.out.print(ch);
ch=(char)System.in.read();
}
}
}
look!
import java.io.*;
public class Test30007 {
public static void main(String[] args)throws IOException{
char ch;
ch=(char)System.in.read();
while(ch!='?'){
if(ch>'a'&&ch<'z')
ch=(char) ( ch+'A'-'a');
else if(ch>'A'&&ch<'Z')
ch=(char) (ch+'a'-'A');
System.out.print(ch);
ch=(char)System.in.read();
}
}
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯