fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7. long double s[n], h=0;
  8. for(int i=0; i<n; i++)
  9. {
  10. cin >> s[i];
  11. h+=s[i];
  12. }
  13. for(int i=0; i<n; i++)
  14. {
  15. cout.precision(4);
  16. cout << fixed << s[i]/h << " ";
  17. }
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 4532KB
stdin
3
2 5 8
stdout
0.1333 0.3333 0.5333