Stuck on an Ada Program - Stuck on Input

前端 未结 2 1941
日久生厌
日久生厌 2020-12-04 03:43

I have a pretty simple Ada project on my hands. The task is to take a collection of a \"voter\'s\" votes and compare it to each \"candidate\'s\" score and determine which ca

2条回答
  •  借酒劲吻你
    2020-12-04 04:26

    You could use streams in order to read the data in: Integer'Read( STREAM_HANDLE, VARIABLE )

    Another option is reading the values via Get for each element of your array, I'd recommend a helper-function in case you need to tweak the procedure for handling format changes:

        Function  Get_Vote ( File  : File_Type ) Return Integer is
        begin
            Return Result : Integer do
                Integer_IO.Get(
                    File  => File,
                    Item  => Result
                   );
            End return;
        end Read_Votes;
    

    and

    For Index in VOTE_ARRAY'range loop
        VOTE_ARRAY( Index ) := Get_Vote( INPUT_FILE );
    End loop;
    

提交回复
热议问题