给位老铁,为啥这题0%?

题目描述
输入一个字符串,求出该字符串包含的字符集合

输入描述:
每组数据输入一个字符串,字符串最大长度为100,且只包含字母,不可能为空串,区分大小写。


输出描述:
每组数据一行,按字符串原有的字符顺序,输出字符集合,即重复出现并靠后的字母不输出。

输入例子:
abcqweracb

输出例子:
abcqwer
————————————————
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;


public class Main12 {

	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String str =sc.nextLine();
		char[] ch=str.toCharArray();
		ArrayList<Character> list =new ArrayList<Character>();
		for(int i=0;i<ch.length;i++){
			if(!(list.contains(ch[i]))){
				list.add( ch[i]);
			}
		}
		
		Iterator it = list.iterator();
		while(it.hasNext()){
			System.out.print(it.next());
		}

		
		

	}

}


#笔试题目#
全部评论
shein的题,你没处理多次输入。就是说要套一个while(sc.hasNext())
点赞 回复 分享
发布于 2019-09-14 11:01
你的逻辑实现不了多行输入啊
点赞 回复 分享
发布于 2019-09-14 12:07
输出一个字符串吧,你这是一个一个字符连着输出,我觉得是你的输出出问题了
点赞 回复 分享
发布于 2019-09-14 10:58

相关推荐

ddd7_:跟我一模一样,加微信的hr都同一个,扫码了白年书人查看图片
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务