two dimentional arrays

[b][red]This message was edited by 97151568 at 2004-6-25 23:20:55[/red][/b][hr]
Hi, im new to pascal. I want to display datas in two dimentional array.

here is my version of two dimentional array, somehow couldn't display anything. can somebody have a look thanks.

[code]
procedure display;
begin
if (FirstYear >= 1985) and (FirstYear <= 1999)
and (LastYear >= 1985) and (LastYear <= 1999)
and (FirstYear <= LastYear) then
for Count := FirstYear to LastYear do
begin
writeln('The sales data of ', Count);
for coumon :=1 to 12 do
writeln(sale[Count, Coumon]);
end;
end;
[/code]


Comments

  • : [b][red]This message was edited by 97151568 at 2004-6-25 23:20:55[/red][/b][hr]
    : Hi, im new to pascal. I want to display datas in two dimentional array.
    :
    : here is my version of two dimentional array, somehow couldn't display anything. can somebody have a look thanks.
    :
    : [code]
    : procedure display;
    : begin
    : if (FirstYear >= 1985) and (FirstYear <= 1999)
    : and (LastYear >= 1985) and (LastYear <= 1999)
    : and (FirstYear <= LastYear) then
    : for Count := FirstYear to LastYear do
    : begin
    : writeln('The sales data of ', Count);
    : for coumon :=1 to 12 do
    : writeln(sale[Count, Coumon]);
    : end;
    : end;
    : [/code]
    :
    :
    :
    It doesn't display anything, because FirstYear and LastYear are 0, which is < 1985, thus the condition of the if-then statement returns false. If you change the code to this, you will see what I mean:
    [code]
    : procedure display;
    : begin
    : if (FirstYear >= 1985) and (FirstYear <= 1999)
    : and (LastYear >= 1985) and (LastYear <= 1999)
    : and (FirstYear <= LastYear) then
    : for Count := FirstYear to LastYear do
    : begin
    : writeln('The sales data of ', Count);
    : for coumon :=1 to 12 do
    : writeln(sale[Count, Coumon]);
    : end
    else
    writeln('Invalid FirstYear (', FirstYear, ') or LastYear (', LastYear, ')');
    : end;
    [/code]
  • : : [b][red]This message was edited by 97151568 at 2004-6-25 23:20:55[/red][/b][hr]
    : : Hi, im new to pascal. I want to display datas in two dimentional array.
    : :
    : : here is my version of two dimentional array, somehow couldn't display anything. can somebody have a look thanks.
    : :
    : : [code]
    : : procedure display;
    : : begin
    : : if (FirstYear >= 1985) and (FirstYear <= 1999)
    : : and (LastYear >= 1985) and (LastYear <= 1999)
    : : and (FirstYear <= LastYear) then
    : : for Count := FirstYear to LastYear do
    : : begin
    : : writeln('The sales data of ', Count);
    : : for coumon :=1 to 12 do
    : : writeln(sale[Count, Coumon]);
    : : end;
    : : end;
    : : [/code]
    : :
    : :
    : :
    : It doesn't display anything, because FirstYear and LastYear are 0, which is < 1985, thus the condition of the if-then statement returns false. If you change the code to this, you will see what I mean:
    : [code]
    : : procedure display;
    : : begin
    : : if (FirstYear >= 1985) and (FirstYear <= 1999)
    : : and (LastYear >= 1985) and (LastYear <= 1999)
    : : and (FirstYear <= LastYear) then
    : : for Count := FirstYear to LastYear do
    : : begin
    : : writeln('The sales data of ', Count);
    : : for coumon :=1 to 12 do
    : : writeln(sale[Count, Coumon]);
    : : end
    : else
    : writeln('Invalid FirstYear (', FirstYear, ') or LastYear (', LastYear, ')');
    : : end;
    : [/code]
    :
    I got the code display now , but its not in two dimentional.. its just like a normal one dimentional array...
  • : : : [b][red]This message was edited by 97151568 at 2004-6-25 23:20:55[/red][/b][hr]
    : : : Hi, im new to pascal. I want to display datas in two dimentional array.
    : : :
    : : : here is my version of two dimentional array, somehow couldn't display anything. can somebody have a look thanks.
    : : :
    : : : [code]
    : : : procedure display;
    : : : begin
    : : : if (FirstYear >= 1985) and (FirstYear <= 1999)
    : : : and (LastYear >= 1985) and (LastYear <= 1999)
    : : : and (FirstYear <= LastYear) then
    : : : for Count := FirstYear to LastYear do
    : : : begin
    : : : writeln('The sales data of ', Count);
    : : : for coumon :=1 to 12 do
    : : : writeln(sale[Count, Coumon]);
    : : : end;
    : : : end;
    : : : [/code]
    : : :
    : : :
    : : :
    : : It doesn't display anything, because FirstYear and LastYear are 0, which is < 1985, thus the condition of the if-then statement returns false. If you change the code to this, you will see what I mean:
    : : [code]
    : : : procedure display;
    : : : begin
    : : : if (FirstYear >= 1985) and (FirstYear <= 1999)
    : : : and (LastYear >= 1985) and (LastYear <= 1999)
    : : : and (FirstYear <= LastYear) then
    : : : for Count := FirstYear to LastYear do
    : : : begin
    : : : writeln('The sales data of ', Count);
    : : : for coumon :=1 to 12 do
    : : : writeln(sale[Count, Coumon]);
    : : : end
    : : else
    : : writeln('Invalid FirstYear (', FirstYear, ') or LastYear (', LastYear, ')');
    : : : end;
    : : [/code]
    : :
    : I got the code display now , but its not in two dimentional.. its just like a normal one dimentional array...
    :
    To get it to be 2D, you need to use a combination of write() and writeln(). See the help files on the difference between the two. Also beware that you need to add some kind of visual indication where one number ends and the next begins.
  • : : : : [b][red]This message was edited by 97151568 at 2004-6-25 23:20:55[/red][/b][hr]
    : : : : Hi, im new to pascal. I want to display datas in two dimentional array.
    : : : :
    : : : : here is my version of two dimentional array, somehow couldn't display anything. can somebody have a look thanks.
    : : : :
    : : : : [code]
    : : : : procedure display;
    : : : : begin
    : : : : if (FirstYear >= 1985) and (FirstYear <= 1999)
    : : : : and (LastYear >= 1985) and (LastYear <= 1999)
    : : : : and (FirstYear <= LastYear) then
    : : : : for Count := FirstYear to LastYear do
    : : : : begin
    : : : : writeln('The sales data of ', Count);
    : : : : for coumon :=1 to 12 do
    : : : : writeln(sale[Count, Coumon]);
    : : : : end;
    : : : : end;
    : : : : [/code]
    : : : :
    : : : :
    : : : :
    : : : It doesn't display anything, because FirstYear and LastYear are 0, which is < 1985, thus the condition of the if-then statement returns false. If you change the code to this, you will see what I mean:
    : : : [code]
    : : : : procedure display;
    : : : : begin
    : : : : if (FirstYear >= 1985) and (FirstYear <= 1999)
    : : : : and (LastYear >= 1985) and (LastYear <= 1999)
    : : : : and (FirstYear <= LastYear) then
    : : : : for Count := FirstYear to LastYear do
    : : : : begin
    : : : : writeln('The sales data of ', Count);
    : : : : for coumon :=1 to 12 do
    : : : : writeln(sale[Count, Coumon]);
    : : : : end
    : : : else
    : : : writeln('Invalid FirstYear (', FirstYear, ') or LastYear (', LastYear, ')');
    : : : : end;
    : : : [/code]
    : : :
    : : I got the code display now , but its not in two dimentional.. its just like a normal one dimentional array...
    : :
    : To get it to be 2D, you need to use a combination of write() and writeln(). See the help files on the difference between the two. Also beware that you need to add some kind of visual indication where one number ends and the next begins.
    :
    I saw this code on the http://www.wiu.edu/users/mflll/cs214/2darrays.htm#Nested for about how to write a 2 dimentional array
    [code]
    For example:
    for row:= 1 to 5 do begin
    for column:= 1 to 10 do begin
    writeln (array[row, column])
    end;
    end;
    [/code]
    by following this tutorial gives me no luck, everything that being outputed is still one dimentional, please help me
  • : : : : : [b][red]This message was edited by 97151568 at 2004-6-25 23:20:55[/red][/b][hr]
    : : : : : Hi, im new to pascal. I want to display datas in two dimentional array.
    : : : : :
    : : : : : here is my version of two dimentional array, somehow couldn't display anything. can somebody have a look thanks.
    : : : : :
    : : : : : [code]
    : : : : : procedure display;
    : : : : : begin
    : : : : : if (FirstYear >= 1985) and (FirstYear <= 1999)
    : : : : : and (LastYear >= 1985) and (LastYear <= 1999)
    : : : : : and (FirstYear <= LastYear) then
    : : : : : for Count := FirstYear to LastYear do
    : : : : : begin
    : : : : : writeln('The sales data of ', Count);
    : : : : : for coumon :=1 to 12 do
    : : : : : writeln(sale[Count, Coumon]);
    : : : : : end;
    : : : : : end;
    : : : : : [/code]
    : : : : :
    : : : : :
    : : : : :
    : : : : It doesn't display anything, because FirstYear and LastYear are 0, which is < 1985, thus the condition of the if-then statement returns false. If you change the code to this, you will see what I mean:
    : : : : [code]
    : : : : : procedure display;
    : : : : : begin
    : : : : : if (FirstYear >= 1985) and (FirstYear <= 1999)
    : : : : : and (LastYear >= 1985) and (LastYear <= 1999)
    : : : : : and (FirstYear <= LastYear) then
    : : : : : for Count := FirstYear to LastYear do
    : : : : : begin
    : : : : : writeln('The sales data of ', Count);
    : : : : : for coumon :=1 to 12 do
    : : : : : writeln(sale[Count, Coumon]);
    : : : : : end
    : : : : else
    : : : : writeln('Invalid FirstYear (', FirstYear, ') or LastYear (', LastYear, ')');
    : : : : : end;
    : : : : [/code]
    : : : :
    : : : I got the code display now , but its not in two dimentional.. its just like a normal one dimentional array...
    : : :
    : : To get it to be 2D, you need to use a combination of write() and writeln(). See the help files on the difference between the two. Also beware that you need to add some kind of visual indication where one number ends and the next begins.
    : :
    : I saw this code on the http://www.wiu.edu/users/mflll/cs214/2darrays.htm#Nested for about how to write a 2 dimentional array
    : [code]
    : For example:
    : for row:= 1 to 5 do begin
    : for column:= 1 to 10 do begin
    : writeln (array[row, column])
    : end;
    : end;
    : [/code]
    : by following this tutorial gives me no luck, everything that being outputed is still one dimentional, please help me
    :
    Here is a small code (based on your program), which creates a horizontal 1D array. From combining these you should be able to create a 2D array output.
    [code]
    : : : : : if (FirstYear >= 1985) and (FirstYear <= 1999)
    : : : : : and (LastYear >= 1985) and (LastYear <= 1999)
    : : : : : and (FirstYear <= LastYear) then
    : : : : : for Count := FirstYear to LastYear do
    : : : : : begin
    : : : : : writeln('The sales data of ', Count);
    : : : : : for coumon :=1 to 12 do
    : : : : : [red]write(sale[Count, Coumon], ' ');[/red]
    : : : : : end
    [/code]
    Only the red line has been changed.
  • : : : : : : [b][red]This message was edited by 97151568 at 2004-6-25 23:20:55[/red][/b][hr]
    : : : : : : Hi, im new to pascal. I want to display datas in two dimentional array.
    : : : : : :
    : : : : : : here is my version of two dimentional array, somehow couldn't display anything. can somebody have a look thanks.
    : : : : : :
    : : : : : : [code]
    : : : : : : procedure display;
    : : : : : : begin
    : : : : : : if (FirstYear >= 1985) and (FirstYear <= 1999)
    : : : : : : and (LastYear >= 1985) and (LastYear <= 1999)
    : : : : : : and (FirstYear <= LastYear) then
    : : : : : : for Count := FirstYear to LastYear do
    : : : : : : begin
    : : : : : : writeln('The sales data of ', Count);
    : : : : : : for coumon :=1 to 12 do
    : : : : : : writeln(sale[Count, Coumon]);
    : : : : : : end;
    : : : : : : end;
    : : : : : : [/code]
    : : : : : :
    : : : : : :
    : : : : : :
    : : : : : It doesn't display anything, because FirstYear and LastYear are 0, which is < 1985, thus the condition of the if-then statement returns false. If you change the code to this, you will see what I mean:
    : : : : : [code]
    : : : : : : procedure display;
    : : : : : : begin
    : : : : : : if (FirstYear >= 1985) and (FirstYear <= 1999)
    : : : : : : and (LastYear >= 1985) and (LastYear <= 1999)
    : : : : : : and (FirstYear <= LastYear) then
    : : : : : : for Count := FirstYear to LastYear do
    : : : : : : begin
    : : : : : : writeln('The sales data of ', Count);
    : : : : : : for coumon :=1 to 12 do
    : : : : : : writeln(sale[Count, Coumon]);
    : : : : : : end
    : : : : : else
    : : : : : writeln('Invalid FirstYear (', FirstYear, ') or LastYear (', LastYear, ')');
    : : : : : : end;
    : : : : : [/code]
    : : : : :
    : : : : I got the code display now , but its not in two dimentional.. its just like a normal one dimentional array...
    : : : :
    : : : To get it to be 2D, you need to use a combination of write() and writeln(). See the help files on the difference between the two. Also beware that you need to add some kind of visual indication where one number ends and the next begins.
    : : :
    : : I saw this code on the http://www.wiu.edu/users/mflll/cs214/2darrays.htm#Nested for about how to write a 2 dimentional array
    : : [code]
    : : For example:
    : : for row:= 1 to 5 do begin
    : : for column:= 1 to 10 do begin
    : : writeln (array[row, column])
    : : end;
    : : end;
    : : [/code]
    : : by following this tutorial gives me no luck, everything that being outputed is still one dimentional, please help me
    : :
    : Here is a small code (based on your program), which creates a horizontal 1D array. From combining these you should be able to create a 2D array output.
    : [code]
    : : : : : : if (FirstYear >= 1985) and (FirstYear <= 1999)
    : : : : : : and (LastYear >= 1985) and (LastYear <= 1999)
    : : : : : : and (FirstYear <= LastYear) then
    : : : : : : for Count := FirstYear to LastYear do
    : : : : : : begin
    : : : : : : writeln('The sales data of ', Count);
    : : : : : : for coumon :=1 to 12 do
    : : : : : : [red]write(sale[Count, Coumon], ' ');[/red]
    : : : : : : end
    : [/code]
    : Only the red line has been changed.
    :
    The code that you give me made the output go across the page, somehow the output is not neat, is there a way to straighten it up ?
    can be something like :
    [code]
    example:
    Year 1985 100 100 50 30 40 60
    Year 1986 300 400 60 40 70 90
    [/code]
  • : : : : : : : [b][red]This message was edited by 97151568 at 2004-6-25 23:20:55[/red][/b][hr]
    : : : : : : : Hi, im new to pascal. I want to display datas in two dimentional array.
    : : : : : : :
    : : : : : : : here is my version of two dimentional array, somehow couldn't display anything. can somebody have a look thanks.
    : : : : : : :
    : : : : : : : [code]
    : : : : : : : procedure display;
    : : : : : : : begin
    : : : : : : : if (FirstYear >= 1985) and (FirstYear <= 1999)
    : : : : : : : and (LastYear >= 1985) and (LastYear <= 1999)
    : : : : : : : and (FirstYear <= LastYear) then
    : : : : : : : for Count := FirstYear to LastYear do
    : : : : : : : begin
    : : : : : : : writeln('The sales data of ', Count);
    : : : : : : : for coumon :=1 to 12 do
    : : : : : : : writeln(sale[Count, Coumon]);
    : : : : : : : end;
    : : : : : : : end;
    : : : : : : : [/code]
    : : : : : : :
    : : : : : : :
    : : : : : : :
    : : : : : : It doesn't display anything, because FirstYear and LastYear are 0, which is < 1985, thus the condition of the if-then statement returns false. If you change the code to this, you will see what I mean:
    : : : : : : [code]
    : : : : : : : procedure display;
    : : : : : : : begin
    : : : : : : : if (FirstYear >= 1985) and (FirstYear <= 1999)
    : : : : : : : and (LastYear >= 1985) and (LastYear <= 1999)
    : : : : : : : and (FirstYear <= LastYear) then
    : : : : : : : for Count := FirstYear to LastYear do
    : : : : : : : begin
    : : : : : : : writeln('The sales data of ', Count);
    : : : : : : : for coumon :=1 to 12 do
    : : : : : : : writeln(sale[Count, Coumon]);
    : : : : : : : end
    : : : : : : else
    : : : : : : writeln('Invalid FirstYear (', FirstYear, ') or LastYear (', LastYear, ')');
    : : : : : : : end;
    : : : : : : [/code]
    : : : : : :
    : : : : : I got the code display now , but its not in two dimentional.. its just like a normal one dimentional array...
    : : : : :
    : : : : To get it to be 2D, you need to use a combination of write() and writeln(). See the help files on the difference between the two. Also beware that you need to add some kind of visual indication where one number ends and the next begins.
    : : : :
    : : : I saw this code on the http://www.wiu.edu/users/mflll/cs214/2darrays.htm#Nested for about how to write a 2 dimentional array
    : : : [code]
    : : : For example:
    : : : for row:= 1 to 5 do begin
    : : : for column:= 1 to 10 do begin
    : : : writeln (array[row, column])
    : : : end;
    : : : end;
    : : : [/code]
    : : : by following this tutorial gives me no luck, everything that being outputed is still one dimentional, please help me
    : : :
    : : Here is a small code (based on your program), which creates a horizontal 1D array. From combining these you should be able to create a 2D array output.
    : : [code]
    : : : : : : : if (FirstYear >= 1985) and (FirstYear <= 1999)
    : : : : : : : and (LastYear >= 1985) and (LastYear <= 1999)
    : : : : : : : and (FirstYear <= LastYear) then
    : : : : : : : for Count := FirstYear to LastYear do
    : : : : : : : begin
    : : : : : : : writeln('The sales data of ', Count);
    : : : : : : : for coumon :=1 to 12 do
    : : : : : : : [red]write(sale[Count, Coumon], ' ');[/red]
    : : : : : : : end
    : : [/code]
    : : Only the red line has been changed.
    : :
    : The code that you give me made the output go across the page, somehow the output is not neat, is there a way to straighten it up ?
    : can be something like :
    : [code]
    : example:
    : Year 1985 100 100 50 30 40 60
    : Year 1986 300 400 60 40 70 90
    : [/code]
    :
    Just what I said a combination of write()'s and writeln()'s. Hint: It is also possible to call writeln() without any parameters, such as this:
    [code]
    writeln;
    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories