这段c语言代码换成java是什么呢?求教啊!?

⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯图片说明图片说明

0

3个回答

package javaOJ;

import java.util.Scanner;

public class c {
public static void main(String[] args) {
String s;
//char[] s = new char[1000];
Scanner scanf = new Scanner(System.in);
while(true)
{
s = scanf.next();
char[] str = s.toCharArray();
// System.out.println(cs[0]);
if(str[0]=='#') break;
// System.out.println(cs.length);
int len=str.length;
for(int i=0;i<len;i++)
{
if(str[i]==' ')
System.out.print("%20");
else if(str[i]=='!')
System.out.print("%21");
else if(str[i]=='$')
System.out.print("%24");
else if(str[i]=='%')
System.out.print("%25");
else if(str[i]=='(')
System.out.print("%28");
else if(str[i]==')')
System.out.print("%29");
else if(str[i]=='*')
System.out.print("%2a");
else
System.out.print(str[i]);
}
System.out.println();
}
}
}

0
package javaOJ;

import java.util.Scanner;

public class c {
public static void main(String[] args) {
String s;
//char[] s = new char[1000];
Scanner scanf = new Scanner(System.in);
while(true)
{
s = scanf.next();
char[] str = s.toCharArray();
// System.out.println(cs[0]);
if(str[0]=='#') break;
// System.out.println(cs.length);
int len=str.length;
for(int i=0;i<len;i++)
{
if(str[i]==' ')
System.out.print("%20");
else if(str[i]=='!')
System.out.print("%21");
else if(str[i]=='$')
System.out.print("%24");
else if(str[i]=='%')
System.out.print("%25");
else if(str[i]=='(')
System.out.print("%28");
else if(str[i]==')')
System.out.print("%29");
else if(str[i]=='*')
System.out.print("%2a");
else
System.out.print(str[i]);
}
System.out.println();
}
}
}

0

意思就是替换数组中一些需要转码的字符

0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!