current position:Home>I want to give some accounts money according to the frozen proportion, but the result is wrong. What's the problem?

I want to give some accounts money according to the frozen proportion, but the result is wrong. What's the problem?

2022-02-03 23:28:22 Q & A of Denglian community

pragma solidity ^0.5.8 ;import "./SafeMath.sol";    contract dropping{        using SafeMath for uint;        mapping(uint256 => address) public NoToAddr;        mapping(address => uint256) public AddTomount;        mapping(address => uint256) public AddToDrop;        uint256 public total;        function testfor(address t1, address t2, address t3, uint256 mount_)public returns(uint256,uint256,uint256){            NoToAddr[0] = t1;            NoToAddr[1] = t2;            NoToAddr[2] = t3;            AddTomount[t1] = 10;            AddTomount[t2] = 20;            AddTomount[t3] = 30;            total = 60;            for(uint256 i = 0; i<=2; i++){                AddToDrop[NoToAddr[i]] += (mount_.mul(AddTomount[NoToAddr[i]])).div(total);            }            return(AddToDrop[t1], AddToDrop[t2], AddToDrop[t3]);        }    }{    "0": "uint256: 300",    "1": "uint256: 1200",    "2": "uint256: 450"}





Other answers 1:

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202032328203716.html

Random recommended