Cho dãy A gồm N số nguyên a1,a2...an trình bày thuật toán đưa ra số lượng các số chẵn có trong dãy đã cho

2 câu trả lời

program Kookie;

uses crt;

var     d, i, N : integer;

begin

clrscr;

write(' nhap vao so phan tu cua day A là :');

readln(N);

for i:=1 to N do

if A[i] mod 2 = 0 then

d := d+1;

writeln(' so ca so chan la :,'d);

readln

end.

- Xác định bài toán :

+ Input : số N và các số hạng a[1], ... , a[N]

+ Output : số lượng các số chẵn có trong dãy đã cho

- Mô tả thuật toán :

+ Bước 1 : nhập số N và các số hạng a[1], ... , a[N]

+ Bước 2 : count ← 0, i ← 1

+ Bước 3 : nếu i > N thì đưa ra giá trị count, kết thúc

+ Bước 4 :

+ Bước 4.1 : nếu a[i] mod 2 = 0 thì count ← count + 1

+ Bước 4.2 : i ← i + 1 quay lại bước 3

Câu hỏi trong lớp Xem thêm

Mark the letter A, B, e,or D to indicate the underlined part that needs correction in each of the following questions. ( sửa lỗi luôn ạ) 51. A lot of people think that marriage women shouldn't pursue a career. A B C D 52. We must stop discrimination on people coming from the rural area. A B C D 53. My brother is good with cooking and he can cook very delicious food. A B C D 54. I guess they may be kept home doing housework and look after their chifdren, A B C D 55. Women in rural areas might be forced to work both at home but on the fields. A B C D 56. Some people think that girls shouldn't be allowed to going to university. A B C D 57. Gender discrimination should be eliminated for create equal opportunities in educationfor everyone. A B C D 58. More girls should being chosen to represent us in the School Youth Union .. A B C D 59. Both women and men should be given equal rights for education and employment. A B C D 60. This discrimination against women and girls must be abolishing. A B C D 61. Efforts should be make to offer all children equal access to education. A B C D 62. It is clear that gender differences cannot prevent a person to pursue a job. A B C D 63. Traditional women were mainly responsible to doing housework and looking after their husbands and A B C D children. 64. Doing houseworkevery day is really boring and tired. A B C D 65. In the past, women was often passive and dependent on their husbands. A B C D 66. Women usually get less pay as men for doing the same job. A B C D

0 lượt xem
2 đáp án
15 giờ trước