![]() |
|
|
Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
Опции темы | Поиск в этой теме | Опции просмотра |
#1
|
|||
|
|||
![]() Код:
[Error] Project1.dpr(25): Operator not applicable to this operand type Код:
program Project1; {$APPTYPE CONSOLE} uses SysUtils; var cityname: array [0..1120] of string; //cityindex: array [0..1120] of Integer; f:Text; s:string; i:Integer; begin { TODO -oUser -cConsole Main : Insert code here } Assign(f,'cities.txt'); Reset(f); for i:=0 to 1120 do Readln(f,cityname[i]); s:='go'; while s <> 'exit' do begin Readln(s); if s in cityname then begin Writeln(s); end else begin Writeln('There is no such city! Try again.'); Readln(s); end; end; Close(f); Readln(s); end. |
#2
|
|||
|
|||
![]() if s in cityname then ??? тут что то не так
если ты хочешь сравнивать s с элементами массива то if s=cityname[i] |
#3
|
|||
|
|||
![]() знаю ГДЕ не знаю ЧТО
|
#4
|
|||
|
|||
![]() Код:
program Project1; {$APPTYPE CONSOLE} uses SysUtils; var cityname: array [0..1120] of string; //cityindex: array [0..1120] of Integer; f:Text; s:string; i:Integer; begin { TODO -oUser -cConsole Main : Insert code here } Assign(f,'cities.txt'); Reset(f); for i:=0 to 1120 do Readln(f,cityname[i]); while s <> 'exit' do begin Readln(s); for i:=0 to 1120 do begin if s=cityname[i] then begin Writeln(s); end else Writeln('There is no such city! Try again.'); end; Readln(s); end; end; Close(f); Readln(s); end. |
#5
|
|||
|
|||
![]() nassvora, я бы не советовал использовать код который привел freedomman..
Я так полагаю вам необходимо определять находится ли имя города в массиве имен до тех пор пока пользователь не введет "exit"? |
#6
|
|||
|
|||
![]() Цитата:
правда сообщение о не том городе выйдет 1120 раз |