日期:2014-05-20 浏览次数:20670 次
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
public class mp {
public static final String[] numbers={"1+5i","2+3i","4-5i","2+8i"};
public static void main(String[] args) {
Map<Integer,Integer> map=new HashMap<Integer,Integer>();
for(String s:numbers){
int real;
int virtue;
int i=0;
for(;i<s.length();i++){
if(s.charAt(i)=='+'
------其他解决方案--------------------
s.charAt(i)=='-') break;
}
real=Integer.parseInt(s.substring(0,i));
virtue=Integer.parseInt(s.substring(i+1,s.length()-1));
System.out.println(real+","+virtue);
map.put(real, virtue);
}
}
}