求大神帮忙将下面的C++改成java

「已注销」 2019-05-09 10:54:39
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
const int N = 1e5 + 5;
typedef long long LL;
using namespace std;
char ar[N];
int main(){
char *s="lovelive";
while(gets(ar)){
int len =strlen(ar);
for(int i=0;i<len;++i){
if(ar[i]>='A'&&ar[i]<='Z')ar[i]+=97-65;
}
if(strcmp(ar,s)==0)printf("yes\n");
else printf("no\n");
}
return 0;
}
...全文
152 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
走好每一步 2019-05-13
  • 打赏
  • 举报
回复
你用的Eclipse吗?我用的是最新的SDK和Eclipse。
「已注销」 2019-05-12
  • 打赏
  • 举报
回复
引用 2 楼 走好每一步 的回复:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Test
{
    public static void main(String[] args)
    {
    	BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    	
    	String line;
    	String str = "lovelive";
    	try 
    	{
			while ((line = reader.readLine()) != null) 
			{
				if (0 == line.compareToIgnoreCase(str)) 
				{
					System.out.println("yes\n");
				} else 
				{
					System.out.println("no\n");
				}
			}
		} 
    	catch (Exception e) 
    	{
			e.printStackTrace();
		}
    	
    	
    }
}
没编译出来
「已注销」 2019-05-12
  • 打赏
  • 举报
回复
引用 1 楼 郅爲 的回复:
对C++不是很熟悉,大致翻译了一下! public class Test { static int N = (int) (1E5 + 5); static char[] ar = new char[N]; public static void main(String[] args) { char[] s="lovelive".toCharArray(); int index = 0; while(index < ar.length) { int len = ar.length; for(int i = 0; i < len; i++) { if(ar[i] >= 'A' && ar[i] <= 'Z') ar[i] += 97-65; } if(String.valueOf(s).equals(String.valueOf(ar))) { System.out.println("yes"); }else { System.out.println("no"); } index++; } } }
哥,按你的编译完,被no刷屏了
走好每一步 2019-05-10
  • 打赏
  • 举报
回复
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Test
{
    public static void main(String[] args)
    {
    	BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    	
    	String line;
    	String str = "lovelive";
    	try 
    	{
			while ((line = reader.readLine()) != null) 
			{
				if (0 == line.compareToIgnoreCase(str)) 
				{
					System.out.println("yes\n");
				} else 
				{
					System.out.println("no\n");
				}
			}
		} 
    	catch (Exception e) 
    	{
			e.printStackTrace();
		}
    	
    	
    }
}
郅嫣 2019-05-10
  • 打赏
  • 举报
回复
对C++不是很熟悉,大致翻译了一下! public class Test { static int N = (int) (1E5 + 5); static char[] ar = new char[N]; public static void main(String[] args) { char[] s="lovelive".toCharArray(); int index = 0; while(index < ar.length) { int len = ar.length; for(int i = 0; i < len; i++) { if(ar[i] >= 'A' && ar[i] <= 'Z') ar[i] += 97-65; } if(String.valueOf(s).equals(String.valueOf(ar))) { System.out.println("yes"); }else { System.out.println("no"); } index++; } } }

50,542

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧