作者game0416 (凤狼)
看板NTUE-CS102
标题Re: [闲聊] 程设作业
时间Thu Oct 28 10:46:14 2010
1F:推 jerry771210:加油吧 这份要拿及格分数大概写个10分钟 10/18 19:36
这要知道方法啊 ̄▽ ̄
某音:「你们这学长的十分钟比人家的十分钟长很多啊」
split()
Double.parseDouble()
toCharArray()
实做一小段范例code作为参考
不要担心,这code写成这样,拿去交大家都知道是抄来的(?)
不过我觉得这样写编译大概也不会过,没debug过,只是一个参考方向(?)
--
double temp;
int pow = 0
boolean negative,point;
for (int i=0;i<input.length;i++){
if ((int)input[i] <= 57 || (int)input[i] >= 48)
if (!point)
temp = temp*10+(input[i]-57);
else
temp = temp + input[i]/ (10*Math.pow((++pow)));
if ((int)input[i] == 45)
negative=true;
if ((int)input[i] == 46)
point =true;
if ((int)input == 44){
if (nagative)
temp*=-1;
array[index++] = temp;
temp=0;
pow=0;
negative=point=0;
}
else{
System.out.print ("input error");
break;
}
}
--
所恐惧的,不是没有知识的大众 所憎恨的,不是深沉幽暗的人心
而是自以为是的思考之声 而是自恃甚高的执法者
所毁灭的,不是温馨和谐的世界 这是我最後的期许,没有愤怒、没有悔恨
而是自欺欺人的梦境 只剩下,浑沌的死亡呼吸
节自 新月神话-弑王者
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 120.127.47.88
※ 编辑: game0416 来自: 120.127.47.88 (10/28 10:54)
2F:→ ming3318:呵呵 真的我打了十分钟也生不出个屁来XD 10/28 11:50
3F:推 Arashinoon:纯推不下 感谢大大无私分享 10/28 14:19
4F:推 j2612280:科科 我写了二个礼拜XD 10/28 15:29
5F:推 SMUGEN:其实..可以用try包住parse然後catch错误就是非数字的情况了 10/28 18:00
6F:推 j2612280:大家都会偷留一手的XD哈哈 10/28 21:59
7F:推 s86186654418:哈哈 快笑 不然人家以为我听不懂 10/28 22:33
8F:推 j2612280:科科干弟 10/28 23:14