fork download
  1. fn main(){
  2. let odds = [1.82, 1.67]; // 배당률
  3. let money = 50000;
  4.  
  5. println!("your money: {}", money);
  6.  
  7. let mut ratios: Vec<f64> = Vec::new(); // 비율
  8.  
  9. // 배당율 순회하면서 비중을 구해서 벡터 생성
  10. for base in odds.iter(){
  11. let mut ratio = 0.0;
  12. for odd in odds.iter(){
  13. ratio += base / odd;
  14. }
  15. ratios.push(1.0/ ratio);
  16. }
  17.  
  18. for (i, r) in ratios.iter_mut().enumerate(){
  19. *r = ((money as f64) * (*r) / 100.0).round() * 100.0;
  20. let expect = (odds[i] * *r / 100.0).round() * 100.0;
  21. println!("Odd:{} Bets: {} Expect: {} Return ratio: {}"
  22. , odds[i]
  23. , *r
  24. , expect
  25. , expect / money as f64);
  26. }
  27. }
Success #stdin #stdout 0s 4432KB
stdin
Standard input is empty
stdout
your money: 50000
Odd:1.82 Bets: 23900 Expect: 43500 Return ratio: 0.87
Odd:1.67 Bets: 26100 Expect: 43600 Return ratio: 0.872