Pascal Reading from the volume of cells



  • We need to: - consider the number of test tests from the first line of the text file (e.g. 2); - second - number of cells (e.g. 5); - from the third is the mass (e.g. 1 2 3 4 5); - with the fourth, again the bulb of the body (e.g. 10); - from the fifth to the rear (e.g. 1 2 3 4 5 6 7 9 10). After certain mass operations, remove converted stocks into a file, for example:

    5

    5 4 3 2 1

    10

    10 9 8 7 6 5 4 3 2 1

    (where: 5 and 10 are the number of elements for each test).

    There's no problem with the mass! How do the first two variables (both tests and elements) and align with the programme so that the programme works independently of the number of checks and components?



  • What does the mission say? In the body and N (1 PO= N PO=10000) chiel. So we're bold.

    var a: array [1..10000] of integer;
    

    10000 won't be necessary. How long does it take to indicate variable n. There's gonna be some more tests. Let it be variable t;

        n: integer;
        t: integer;
    

    begin

    ...
    
    ReadLn(f1, t); // прочитали количество тестов
    for i : = 1 to t do begin // цикл по количеству тестов
    
        Readln(f1, n); // прочитать количество элементов очередного массива
    
        for i := 1 to n do Read(f1, a[i]); // вычитываем n элементов
        ReadLn(f1); // перейти на следующую строку.
    
        for i := 1 to n do begin // это цикл обработки массива. n элементов.
           ...
        end;
    
    end;
    
    ...
    

    end.

    ReadLn(f1) - move to the next line.
    ReadLn(f1, n) - count the number from the file and move to the next line.
    for i := 1 to n do - Cycle from unit to number specified in variable n instead of fiscal 10 or 10000.

    And the entry file is completely inconsistent with the target


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2