|
damka_00 0 / 0 / 0 Регистрация: 29.03.2015 Сообщений: 94 |
||||
|
1 |
||||
Ошибка: ожидался порядковый тип27.04.2016, 20:22. Показов 42512. Ответов 3 Метки нет (Все метки)
Помогите исправить
__________________
0 |
|
Хитрая блондиночка $) 1470 / 985 / 399 Регистрация: 21.12.2015 Сообщений: 3,785 |
|
|
27.04.2016, 20:34 |
2 |
|
for i := 1 to m do begin В этот цикл нельзя счетчиком передавать вещественное число. Либо делай i целочисленным, либо не используй for.
0 |
|
damka_00 0 / 0 / 0 Регистрация: 29.03.2015 Сообщений: 94 |
||||
|
27.04.2016, 20:55 [ТС] |
3 |
|||
|
Я уже и сам додумался сделать i целочисленным ,но спасибо за ответ.И как закрыть тему? Добавлено через 13 минут
0 |
|
capricornus CF 318 / 208 / 162 Регистрация: 08.12.2015 Сообщений: 863 |
||||
|
27.04.2016, 22:35 |
4 |
|||
|
Решение
0 |
- Регистрация
- 29 Авг 2013
- Сообщения
- 89
- Репутация
-
0
- Спасибо
- 0
- Монет
-
0
-
#1
Var k,i,x,n:real;
begin;
for i:=1 to n+1 do
readln(k);
begin
k:=x-n/x-(n-1);
writeln (k)
end;
end.
выдаёт ошибку Program1.pas(4) : Ожидался порядковый тип
- Регистрация
- 28 Июн 2013
- Сообщения
- 52
- Репутация
-
0
- Спасибо
- 0
- Монет
-
0
-
#2
Var k,x:real;
i,n: integer;
- Регистрация
- 28 Авг 2013
- Сообщения
- 80
- Репутация
-
0
- Спасибо
- 0
- Монет
-
0
-
#3
Эта программа не могла работать!
Даже если i и n сделать переменными перечислимого типа, откомпилировать и запустить программу, то всё равно получите ошибку.
У вас будет ошибка деления на 0
- Регистрация
- 28 Дек 2013
- Сообщения
- 60
- Репутация
-
0
- Спасибо
- 0
- Монет
-
0
-
#4
ну там же название программы первым писалось, извините 15 лет прошло. потом подключение модулей, а потом переменные.
- Регистрация
- 21 Окт 2013
- Сообщения
- 71
- Репутация
-
0
- Спасибо
- 0
- Монет
-
0
-
#5
ну так ответ в самой ошибке — строка 4, ожидался порядковый тип.
Эх, паскаль… проверить все точки с запятыми первым делом. Почему нет всяких там юсесов? Где Програм Програм1?
Двадцать лет назад… какой же я старый…
- Регистрация
- 21 Сен 2013
- Сообщения
- 82
- Репутация
-
0
- Спасибо
- 0
- Монет
-
0
-
#6
real — не перечислимый (порядковый) тип. А для переменной цикла нужен перечислимый.
Похожие темы
I need to run a loop for 10 billion times and failing to run it, please help me get this done. I am getting ordinal error.
program kittu;
var i:qword;
j:qword;
k:qword;
begin
i:= 10000000000;
k:= 0;
for j:=1 to i do
begin
k:=k+1;
end;
writeln(k);
readln();
end.
MHosafy
1763 silver badges12 bronze badges
asked Nov 23, 2017 at 2:31
2
From the FreePascal docs for this error message.
Error: Ordinal expression expected The expression must be of ordinal
type, i.e., maximum a Longint. This happens, for instance, when you
specify a second argument to Inc or Dec that doesn’t evaluate to an
ordinal value.
Your variable K is defined as qword, which is a 64-bit length. LongInt is 32 bit.
answered Nov 23, 2017 at 2:39
Sam MSam M
4,1184 gold badges25 silver badges41 bronze badges
1
The for statement is platform dependent.
Observation: qword is not supported to be used as a counter variable on 32-bit platform.
But seems no documentary support to tell which set of datatypes are supported to be used as counter variables.
Tried in both 32-bit and 64-bit platforms:
32-bit:
declaration of variable j could be changed to datatype dword to get it successfully compiled.
It is also required to compile with release mode to prevent getting an error due to overflow.
Compiler: Free Pascal IDE for Win32 for i386
Target CPU: i386
Version 1.0.12 2017/02/13
Compiler Version: 3.0.2
Environment: Win10
edit:
Successfully compiled with i386 free pascal with x86_64 cross compiler
on 64-bit Win10 (edit2: in the left hand side’s command line)
[Image]
Guess: the counter in for statement might be optimized with using registers. Under i386 configuration, qword is too large for a 32-bit register.
64-bit:
[Image]
But it seems to work fine in 64-bit platform.
Compiler: Free Pascal Compiler version 3.0.2 [2017/03/18] for x86_64
Environment: Mac OSX 10.11.6
answered Nov 23, 2017 at 12:35
3
I need to run a loop for 10 billion times and failing to run it, please help me get this done. I am getting ordinal error.
program kittu;
var i:qword;
j:qword;
k:qword;
begin
i:= 10000000000;
k:= 0;
for j:=1 to i do
begin
k:=k+1;
end;
writeln(k);
readln();
end.
MHosafy
1763 silver badges12 bronze badges
asked Nov 23, 2017 at 2:31
2
From the FreePascal docs for this error message.
Error: Ordinal expression expected The expression must be of ordinal
type, i.e., maximum a Longint. This happens, for instance, when you
specify a second argument to Inc or Dec that doesn’t evaluate to an
ordinal value.
Your variable K is defined as qword, which is a 64-bit length. LongInt is 32 bit.
answered Nov 23, 2017 at 2:39
Sam MSam M
4,1184 gold badges25 silver badges41 bronze badges
1
The for statement is platform dependent.
Observation: qword is not supported to be used as a counter variable on 32-bit platform.
But seems no documentary support to tell which set of datatypes are supported to be used as counter variables.
Tried in both 32-bit and 64-bit platforms:
32-bit:
declaration of variable j could be changed to datatype dword to get it successfully compiled.
It is also required to compile with release mode to prevent getting an error due to overflow.
Compiler: Free Pascal IDE for Win32 for i386
Target CPU: i386
Version 1.0.12 2017/02/13
Compiler Version: 3.0.2
Environment: Win10
edit:
Successfully compiled with i386 free pascal with x86_64 cross compiler
on 64-bit Win10 (edit2: in the left hand side’s command line)
[Image]
Guess: the counter in for statement might be optimized with using registers. Under i386 configuration, qword is too large for a 32-bit register.
64-bit:
[Image]
But it seems to work fine in 64-bit platform.
Compiler: Free Pascal Compiler version 3.0.2 [2017/03/18] for x86_64
Environment: Mac OSX 10.11.6
answered Nov 23, 2017 at 12:35
3


Сообщение было отмечено Памирыч как решение