Предмет: Информатика,
автор: JohnCena99
Найти сумму положительных нечетных чисел, меньших 100.
Ответы
Автор ответа:
0
var i,sum:integer;
begin
sum:=0;
for i:=1 to 100 do
if i mod 2 = 1 then sum:=sum+i;
writelnI(sum);
end.
Типо того:
#include
#include
#include
#include
#include
using namespace std;
int main()
{
int summ = 0;
for (int i = 1; i < N; i+=2)
{
_asm
{
mov ebx, [i]
shl ebx, 2
lea esi, arr
add esi, ebx
lodsd
cmp eax, 100
ja _next
test eax, 0x80000000
jnz _next
test eax, 0x1
jnz _next
add summ, eax
_next:
}
}
cout << summ;
return 0;
}
Автор ответа:
0
Ответ:
program gg;
uses crt;
var
a:array[1..10] of integer;
sum,i:integer;
begin
clrscr;
writeln('vvedite 4isla');
for i:=1 to 10 do
readln(a[i]);
for i:=1 to 10 do
if (a[i]>0) and (a[i] mod 2 <>0) and (a[i]<100)
then begin
sum:=sum+a[i];
end;
writeln('summa: ',sum);
readln;
end.
Объяснение:
Типо того:
#include
#include
#include
#include
#include
using namespace std;
int main()
{
int summ = 0;
for (int i = 1; i < N; i+=2)
{
_asm
{
mov ebx, [i]
shl ebx, 2
lea esi, arr
add esi, ebx
lodsd
cmp eax, 100
ja _next
test eax, 0x80000000
jnz _next
test eax, 0x1
jnz _next
add summ, eax
_next:
}
}
cout << summ;
return 0;
}
Подробнее - на Znanija.com - https://znanija.com/task/35529815#readmore
Интересные вопросы
Предмет: Английский язык,
автор: irasopa
Предмет: Английский язык,
автор: Аноним
Предмет: Русский язык,
автор: rsg0710357
Предмет: Математика,
автор: suren8
Предмет: Математика,
автор: annarachenko1
Типо того:
#include
#include
#include
#include
#include
using namespace std;
int main()
{
int summ = 0;
for (int i = 1; i < N; i+=2)
{
_asm
{
mov ebx, [i]
shl ebx, 2
lea esi, arr
add esi, ebx
lodsd
cmp eax, 100
ja _next
test eax, 0x80000000
jnz _next
test eax, 0x1
jnz _next
add summ, eax
_next:
}
}
cout << summ;
return 0;
}
Подробнее - на Znanija.com - https://znanija.com/task/35529815#readmore