|
|
вернуться в форумПоказать все сообщения Спрятать все сообщения#include<iostream> #include<iomanip> #include<math.h> using namespace std; double a[10001]; int main() { int l=0,i,n,k; double x,m; cin>>n>>m; for(i=0;i<m;i++) { cin>>k; a[k]++; } for(i=1;i<=n;i++) { x=a[i]/m; x*=100; if(ceil(x)==floor(x))cout<<x<<".00%"<<endl; else cout<<setprecision(4)<<x<<'%'<<endl; } return 0; } Edited by author 09.04.2008 22:50 I have this Problem too. plz help, my program is been written in JAVA. Edited by author 13.10.2011 16:36 So, I have this problem too. What is the rigth solution? --- I found the answer, use Console.WriteLine("{0:f2}%", t); Edited by author 25.10.2012 19:37 Edited by author 25.10.2012 19:37 Try these inputs: 2 11 1 2 2 2 2 2 2 2 2 2 2 I change this >> first multiply 100 and then divide m . and it works. |
|
|