Array Division - What is the best way to divide two numbers stored in an array?

前端 未结 7 1180
名媛妹妹
名媛妹妹 2021-01-13 16:51

I have two arrays (dividend, divisor):

dividend[] = {1,2,0,9,8,7,5,6,6};
divisor[] = {9,8};

I need the result (dividend/divisor) as:

<
相关标签:
7条回答
  • 2021-01-13 17:40

    Why not convert them to integers and then use regular division?

    in pseudocode:

    int dividend_number
    foreach i in dividend
        dividend_number *= 10
        dividend_number += i
    
    int divisor_number
    foreach i in divisor
        divisor_number *= 10
        divisor_number += i
    
    int answer = dividend_number / divisor_number;
    
    0 讨论(0)
提交回复
热议问题