Вопрос школьника по предмету Информатика
Составьте программы на языке паскаля (10 класс)
1.Дан двухмерный массив А ( размер произвольный). Элементы вводятся с клавиатуры. Вывести только четные элементы.
2.В заданном двухмерном массиве (3 на 3), подсчитать количество чисел которые при делении на 3 дают в остатке 2.
3.Найти сумму элементов двухмерного массива больших 30. Элементы вводятся с клавиатуры
Ответ учителя по предмету Информатика
Ответ:
1. program Hello;
var i,j:integer; A:array [1..10, 1..10] of integer;
begin
for i:=1 to 10 do for j:=1 to 10 do readln(A[i,j]);
for i:=1 to 10 do for j:=1 to 10 do if A[i,j] mod 2 = 0 then writeln(A[i,j]);
end.
2. program Hello2;
var i,j,c:integer; A:array [1..3,1..3] of integer;
begin
c:=0;
for i:=1 to 3 do for j:=1 to 10 do readln(A[i,j]);
for i:=1 to 3 do for j:=1 to 10 do if A[i,j] mod 3 = 2 then c:=c+1;
writeln(c);
end.
3. program Hello3;
var i,j,c:integer; A:array [1..3,1..3] of integer;
begin
c:=0;
for i:=2 to 3 do for j:=1 to 10 do readln(A[i,j]);
for i:=2 to 3 do for j:=1 to 10 do if A[i,j-1] + A[i,j] > 30 then c:=c+1;
for i:=2 to 3 do for j:=1 to 10 do if A[i-1,j] + A[i,j] > 30 then c:=c+1;
end.
Похожие вопросы от пользователей
Понравилась ли вам эта детская игра?Какой она вам показалась-весёлой,смешной,наивной?
Опечатки в учебнике нет!
(помогите пожалуйста)
A CLEVER SHOPLIFTER
The manager of a supermarket overheard a man who was boasting about how much he had been stealing from the store. When the man came in the next day, the manager followed him around. The man bought a lot of things, and stood in a queue under the sign “Shoplifters shall be prosecuted.” Then he paid for everything and loaded his cart. After that he rolled the cart to his car and put the packets into it.
In the weeks that followed the man often came to the shop, loaded his cart with packets and tins and boxes. Each time he paid for every single item. Finally, the manager came up to him and said, “Mister, I’ve been watching you like a hawk. I’ve never seen you pocket one thing. You’ve never hidden anything under your coat. And you’ve paid for every item you’ve bought. Look, I won’t say a word to anyone. In fact, I’ll give you a hundred dollars if you tell me what you’re stealing.” The man smiled and said, “Shopping carts.”