#include
#include
using namespace std;
int main(){
double x;
cin>>x;
cout <<fixed<<setprecision(2)<<x<<endl;
}
這樣寫在DEVC++執行可以
d561. 被秒殺的四捨五入 -- jack1 |
×
查看評分詳細結果。hint Complete
Close
|
×
查看程式碼 #364516 d561. 被秒殺的四捨五入 --
jack1
sub ok(byval strx as string) dim f as string = trim(strx) & "00000" dim v as integer = instr(f,".") dim s as string = mid(f,1,v-1) dim i as integer = val(mid(f,v+1,1)) dim j as integer = val(mid(f,v+2,1)) dim k as integer = val(mid(f,v+3,1)) if k > 4 then j += 1 if j > 9 then j -= 10 i += 1 end if if i > 9 then i -= 10 if instr(s,"-") > 0 then s = "-1" else s = "1" end if end if dim o as string = s & "." & str(i) & str(j) if o = "-0.00" then o = "0.00" print o end sub dim s as string open cons for input as #1 do input #1, s if trim(s)<>"" then ok(s) end if loop until eof(1) Close
×
查看程式碼 #364516 d561. 被秒殺的四捨五入 --
jack1
solutioncode Close
| 2009-12-07 14:29 |
basic 也可以耶
#include
#include
using namespace std;
int main(){
double x;
cin>>x;
cout <<setprecision(2)<<fixed<<x<<endl;
}
上一篇寫錯寫錯
位置要對調過來
這樣寫在DEVC++執行可以
d561. 被秒殺的四捨五入 -- jack1 |
×
查看評分詳細結果。hint Complete
Close
|
×
查看程式碼 #364516 d561. 被秒殺的四捨五入 --
jack1
sub ok(byval strx as string) dim f as string = trim(strx) & "00000" dim v as integer = instr(f,".") dim s as string = mid(f,1,v-1) dim i as integer = val(mid(f,v+1,1)) dim j as integer = val(mid(f,v+2,1)) dim k as integer = val(mid(f,v+3,1)) if k > 4 then j += 1 if j > 9 then j -= 10 i += 1 end if if i > 9 then i -= 10 if instr(s,"-") > 0 then s = "-1" else s = "1" end if end if dim o as string = s & "." & str(i) & str(j) if o = "-0.00" then o = "0.00" print o end sub dim s as string open cons for input as #1 do input #1, s if trim(s)<>"" then ok(s) end if loop until eof(1) Close
×
查看程式碼 #364516 d561. 被秒殺的四捨五入 --
jack1
solutioncode Close
| 2009-12-07 14:29 |
basic 也可以耶