Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 14.04.2012, 20:21   #1
silverandsilver
 
Регистрация: 14.04.2012
Сообщений: 9
По умолчанию проблема с кодом!ошибка!

E2010 Incompatible types: 'Unit2.TArray' and 'Unit1.TArray'

прога с доп модулем

Код:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, StdCtrls, Unit2, About, Content, Menus;

type
  TArray = array of integer;
  TForm1 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Button1: TButton;
    StringGrid1: TStringGrid;
    Label2: TLabel;
    Button2: TButton;
    StringGrid2: TStringGrid;
    Label3: TLabel;
    MainMenu1: TMainMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    N3: TMenuItem;
    N4: TMenuItem;
    N5: TMenuItem;
    N6: TMenuItem;
    N7: TMenuItem;
    N8: TMenuItem;
    N9: TMenuItem;
    N10: TMenuItem;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    PopupMenu1: TPopupMenu;
    N11: TMenuItem;
    N12: TMenuItem;
    StringGrid3: TStringGrid;
    Label4: TLabel;
    N13: TMenuItem;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure N4Click(Sender: TObject);
    procedure N10Click(Sender: TObject);
    procedure N9Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure N3Click(Sender: TObject);
    procedure N13Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  n,l: integer;
  c,d,h,x,y,z: TArray;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject); //Кнопка "Ввод длины массива"
var i: integer;
begin
 n := StrToInt(Edit1.Text);
 StringGrid1.ColCount := n+1;
 StringGrid2.ColCount := n+1;
 StringGrid3.ColCount := n+1;
 for i := 1 to n do
   StringGrid1.Cells[i,0] := IntToStr(i);
for i := 1 to n do
   StringGrid2.Cells[i,0] := IntToStr(i);
   for i := 1 to n do
   StringGrid3.Cells[i,0] := IntToStr(i);
end;

procedure TForm1.Button2Click(Sender: TObject); //Кнопка "Вычислить"
var
i: integer;
begin
 n := StrToInt(Edit1.Text);
 For i:=1 to n do
 x[i]:=StrToint(StringGrid1.Cells[i,1]);
 For i:=1 to n do
 y[i]:=StrToint(StringGrid3.Cells[i,1]);
 obr(n,x,y,z,l);
 StringGrid2.ColCount:=l+1;
 for i:=1 to l do
 StringGrid2.Cells[i,1]:=intToStr(z[i]);

 end;
 



procedure TForm1.N10Click(Sender: TObject);
begin
 ShowMessage('Лабораторная работа №8');
end;

procedure TForm1.N13Click(Sender: TObject);
begin
aboutbox.Show;
end;

procedure TForm1.N2Click(Sender: TObject); // Пункт главного меню "Ввод из файла"
var f: TextFile;
    i: integer;
begin
 if OpenDialog1.Execute then
  begin
    AssignFile(f,OpenDialog1.FileName);
    Reset(f);
    Readln(f,n);
    Edit1.Text := IntToStr(n);
    SetLength(c,n);
    SetLength(d,n);
    SetLength(h,n);
    for i := 0 to n-1 do
      Read(f,c[i]);
      for i := 0 to n-1 do
      Read(f,h[i]);
    Readln(f);
    CloseFile(f);
    StringGrid1.ColCount := n+1;
    StringGrid2.ColCount := n+1;
    StringGrid3.ColCount := n+1;
    for i := 1 to n do
      StringGrid1.Cells[i,0] := IntToStr(i);
    for i := 1 to n do
      StringGrid2.Cells[i,0] := IntToStr(i);
      for i := 1 to n do
      StringGrid3.Cells[i,0] := IntToStr(i);
    for i := 0 to n-1 do
      StringGrid1.Cells[i+1,1] := FloatToStr(c[i]);
      for i := 0 to n-1 do
      StringGrid3.Cells[i+1,1] := FloatToStr(h[i]);
  end;
end;

procedure TForm1.N3Click(Sender: TObject); // Пункт главного меню "Вывод в файл"
var f: TextFile;
    i: integer;
begin
 if SaveDialog1.Execute then
  begin
   AssignFile(f,SaveDialog1.FileName);
   ReWrite(f);
   Writeln(f,Edit1.Text);
   for i := 1 to n do
     Write(f,StringGrid1.Cells[i,1],' ');
     Writeln(f);
     for i := 1 to n do
     Write(f,StringGrid3.Cells[i,1],' ');
   Writeln(f);
   Writeln(f,'Результат:');
   for i := 1 to l do
     Write(f,StringGrid2.Cells[i,1],' ');
   CloseFile(f);
  end;
end;

procedure TForm1.N4Click(Sender: TObject);
begin
 Close;
end;

procedure TForm1.N9Click(Sender: TObject);
begin
contentbox.Show;
end;

end.
доп модуль
Код:
unit Unit2;


interface


type
 TArray = array of integer;

procedure obr(n: integer;s,k:Tarray; var g: TArray;d:integer);

implementation
 // Основной обработчик
procedure obr;
var i,j: integer;
begin
for i:=1 to n do
g[i]:=0;
d:=0;
for i:=1 to n do
 for j:=1 to n do
 if k[i]=s[j] then
 begin
 d:=d+1;
 g[d]:=s[i];
end;
end;

end.
пожалуйста)

з.ы. объектный паскаль. юзаю борланд.
silverandsilver вне форума Ответить с цитированием
Старый 14.04.2012, 21:03   #2
denisbrain
Форумчанин
 
Регистрация: 29.05.2011
Сообщений: 449
По умолчанию

узнаю пример
Legion.lex не из вашего универа?

Incompatible types: 'Unit2.TArray' and 'Unit1.TArray' Несовместимые типы
уберите описание типа из 1 модуля.
задания на pascal/delphi ICQ 368254335
Tel +79177425326 mail denis-naymov1985(at)mail.ru login skype denis.new.skype
denisbrain вне форума Ответить с цитированием
Старый 14.04.2012, 21:28   #3
silverandsilver
 
Регистрация: 14.04.2012
Сообщений: 9
По умолчанию

так было

x[i]:=StrToint(StringGrid1.Cells[i,1]);
тогда на эту строчку ругается
silverandsilver вне форума Ответить с цитированием
Старый 15.04.2012, 07:38   #4
denisbrain
Форумчанин
 
Регистрация: 29.05.2011
Сообщений: 449
По умолчанию

Цитата:
Сообщение от silverandsilver Посмотреть сообщение
так было

x[i]:=StrToint(StringGrid1.Cells[i,1]);
тогда на эту строчку ругается
либо что то не понимаю, либо куча ошибок с размерами массива т.е. с использованием функции
Setlength(Array,Count_Array);
задания на pascal/delphi ICQ 368254335
Tel +79177425326 mail denis-naymov1985(at)mail.ru login skype denis.new.skype
denisbrain вне форума Ответить с цитированием
Старый 15.04.2012, 13:13   #5
silverandsilver
 
Регистрация: 14.04.2012
Сообщений: 9
По умолчанию

вчера мучался мучался. теперь ошибок не выдает. но и массив не выдает. кол каунт убирает и вообще ниче не выводит. похоже процедура не вызывается. хз почему.
вот код измененный.
Код:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, StdCtrls, Unit2, About, Content, Menus;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Button1: TButton;
    StringGrid1: TStringGrid;
    Label2: TLabel;
    Button2: TButton;
    StringGrid2: TStringGrid;
    Label3: TLabel;
    MainMenu1: TMainMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    N3: TMenuItem;
    N4: TMenuItem;
    N5: TMenuItem;
    N6: TMenuItem;
    N7: TMenuItem;
    N8: TMenuItem;
    N9: TMenuItem;
    N10: TMenuItem;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    PopupMenu1: TPopupMenu;
    N11: TMenuItem;
    N12: TMenuItem;
    StringGrid3: TStringGrid;
    Label4: TLabel;
    N13: TMenuItem;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure N4Click(Sender: TObject);
    procedure N10Click(Sender: TObject);
    procedure N9Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure N3Click(Sender: TObject);
    procedure N13Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  n,l,t: integer;
  c,d,h,x,y,g:array of integer;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject); //Кнопка "Ввод длины массива"
var i: integer;
begin
 n := StrToInt(Edit1.Text);
 StringGrid1.ColCount := n+1;
 StringGrid2.ColCount := n+1;
 StringGrid3.ColCount := n+1;
 for i := 1 to n do
   StringGrid1.Cells[i,0] := IntToStr(i);
for i := 1 to n do
   StringGrid2.Cells[i,0] := IntToStr(i);
   for i := 1 to n do
   StringGrid3.Cells[i,0] := IntToStr(i);
end;

procedure TForm1.Button2Click(Sender: TObject); //Кнопка "Вычислить"
var
i: integer;
begin
n := StrToInt(Edit1.Text);
SetLength(x,n);
SetLength(y,n)   ;
SetLength(g,n);
 For i:=1 to n-1 do
 x[i]:=StrToint(StringGrid1.Cells[i,1]);
 For i:=1 to n-1 do
 y[i]:=StrToint(StringGrid3.Cells[i,1]);
 obr(n,x,y,g,t);
 StringGrid2.ColCount:=t+1;
 for i:=1 to t-1 do
 StringGrid2.Cells[i,1]:=intToStr(g[i]);

 end;
 



procedure TForm1.N10Click(Sender: TObject);
begin
 ShowMessage('Лабораторная работа №8');
end;

procedure TForm1.N13Click(Sender: TObject);
begin
aboutbox.Show;
end;

procedure TForm1.N2Click(Sender: TObject); // Пункт главного меню "Ввод из файла"
var f: TextFile;
    i: integer;
begin
 if OpenDialog1.Execute then
  begin
    AssignFile(f,OpenDialog1.FileName);
    Reset(f);
    Readln(f,n);
    Edit1.Text := IntToStr(n);
    SetLength(c,n);
    SetLength(d,n);
    SetLength(h,n);
    for i := 0 to n-1 do
      Read(f,c[i]);
      for i := 0 to n-1 do
      Read(f,h[i]);
    Readln(f);
    CloseFile(f);
    StringGrid1.ColCount := n+1;
    StringGrid2.ColCount := n+1;
    StringGrid3.ColCount := n+1;
    for i := 1 to n do
      StringGrid1.Cells[i,0] := IntToStr(i);
    for i := 1 to n do
      StringGrid2.Cells[i,0] := IntToStr(i);
      for i := 1 to n do
      StringGrid3.Cells[i,0] := IntToStr(i);
    for i := 0 to n-1 do
      StringGrid1.Cells[i+1,1] := FloatToStr(c[i]);
      for i := 0 to n-1 do
      StringGrid3.Cells[i+1,1] := FloatToStr(h[i]);
  end;
end;

procedure TForm1.N3Click(Sender: TObject); // Пункт главного меню "Вывод в файл"
var f: TextFile;
    i: integer;
begin
 if SaveDialog1.Execute then
  begin
   AssignFile(f,SaveDialog1.FileName);
   ReWrite(f);
   Writeln(f,Edit1.Text);
   for i := 1 to n do
     Write(f,StringGrid1.Cells[i,1],' ');
     Writeln(f);
     for i := 1 to n do
     Write(f,StringGrid3.Cells[i,1],' ');
   Writeln(f);
   Writeln(f,'Результат:');
   for i := 1 to l do
     Write(f,StringGrid2.Cells[i,1],' ');
   CloseFile(f);
  end;
end;

procedure TForm1.N4Click(Sender: TObject);
begin
 Close;
end;

procedure TForm1.N9Click(Sender: TObject);
begin
contentbox.Show;
end;

end.
и модуль

Код:
unit Unit2;


interface




procedure obr(n: integer;s,k:array of integer; var g: Array of integer;var t:integer);

implementation
 // Основной обработчик
procedure obr;

var i,j: integer;
begin
for i:=1 to n-1 do
g[i]:=0;
t:=0;
for i:=1 to n-1 do
 for j:=1 to n-1 do
 if k[i]=s[j] then
 begin
 t:=t+1;
 g[t]:=s[i];
end;
end;

end.
silverandsilver вне форума Ответить с цитированием
Старый 15.04.2012, 14:47   #6
silverandsilver
 
Регистрация: 14.04.2012
Сообщений: 9
По умолчанию

нароод,помогите пожалуйста.
silverandsilver вне форума Ответить с цитированием
Старый 15.04.2012, 16:02   #7
Stilet
Белик Виталий :)
Старожил
 
Аватар для Stilet
 
Регистрация: 23.07.2007
Сообщений: 57,097
По умолчанию

Тебе лучше прикрепить сюда архив с проектом, ибо пересобирать все твои компоненты - monkey bussiness
I'm learning to live...
Stilet вне форума Ответить с цитированием
Старый 15.04.2012, 17:31   #8
silverandsilver
 
Регистрация: 14.04.2012
Сообщений: 9
По умолчанию

точняк.
проект тут

помогите пожалуйста...)
silverandsilver вне форума Ответить с цитированием
Старый 15.04.2012, 18:13   #9
Stilet
Белик Виталий :)
Старожил
 
Аватар для Stilet
 
Регистрация: 23.07.2007
Сообщений: 57,097
По умолчанию

Цитата:
for i:=1 to n+1 do
Зачем? Выходишь за пределы массива
Цитата:
procedure obr;

var i,j: integer;
begin
for i:=1 to n-1 do
g[i]:=0;
t:=0;
for i:=1 to n-1 do
for j:=1 to n-1 do
if k[i]=s[j] then
begin
t:=t+1;
g[t]:=s[i];
end;
end;
Что вообще здесь происходит???
Или вернее что должно происходить?
I'm learning to live...
Stilet вне форума Ответить с цитированием
Старый 15.04.2012, 19:36   #10
silverandsilver
 
Регистрация: 14.04.2012
Сообщений: 9
По умолчанию

должен из двух массивов которые вводишь выводить одинаковые элементы в третий.

с счетчиками я уже от безысходности баловался
silverandsilver вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Проблема с кодом. Blind Guard Общие вопросы C/C++ 1 20.03.2012 20:58
проблема с кодом net_probelam Общие вопросы C/C++ 1 19.10.2011 02:06
Проблема с кодом в VB, ошибка в вычислении факториала Богдан Величко Помощь студентам 1 10.04.2011 22:50
Проблема с кодом. scottie Паскаль, Turbo Pascal, PascalABC.NET 3 11.04.2010 15:44
Проблема с кодом( DM_bite Помощь студентам 3 02.08.2008 20:02