Assuming they are both the same level/stats and that magikarp has at least one attacking move, Magikarp would win because ditto would have to waste a turn using Transform
Don't forget to take into account critical hits, avoiding the attack, the fact that ditto will have 5 moves in each attack, and will struggle first. Then there is the HP issue, stats, and whether Magikarp even knows tackle or flail
