If some datas is inputted.. you must check it. ZIGZAG or not...
If not, you must write some data who doesn't support ZIGZAG
Examples:
--------------------------------------------------------
Input:
5
6
2
7
5
9
Output:
ZIGZAG
Contoh lagi..
Input:
5
4
2
3
5
7
Output:
3 5 7
--------------------------------------------------------
OK... maybe you confuse... but.. array statement can be "Played" by programmer
try to read this code carefully and try it at your pascal program
--------------------------------------------------------
var
a,error1,error2,error3 : array[1..1000] of integer;
i,n,cek,error : integer;
begin
error := 0;
write('masukkan jumlah data maksimal : '); readln(n);
for i := 1 to n do
begin
write('masukkan data-data : '); readln(a[i]);
end;
for i := 2 to n - 1 do
begin
if (i mod 2 = 0) then begin
if ((a[i] < a[i + 1]) and (a[i] < a[i - 1])) or ((a[i] > a[i + 1]) and (a[i] > a[i - 1])) then
begin
cek := 1;
end else begin
error := 1;
error1[i] := a[i-1];
error2[i] := a[i];
error3[i] := a[i+1];
end;
end;
end;
if (cek = 1) and (error1[i] = 0) and (error2[i] = 0) and (error3[i] = 0) then begin
writeln('ZIGZAG');
end else begin
writeln(error1[i],' ',error2[i],' ',error3[i]);
end;
readln;
end.
--------------------------------------------------------
Do you know about ZIGZAG?
Illustrate this:
"if you have three datas, fisrt data and third data must be least or more that second data"
So, you look at this code
--------------------------------------------------------
for i := 2 to n - 1 do
begin
if (i mod 2 = 0) then begin
if ((a[i] < a[i + 1]) and (a[i] < a[i - 1])) or ((a[i] > a[i + 1]) and (a[i] > a[i - 1])) then
begin
cek := 1;
--------------------------------------------------------
Jam
Menu Software
Computer English
Link
Menu Blog
Promotion Blogs
ShoutBox
Welcome Word
Selamat Datang Di Blog ini...
Kalendar
Blog Archive
Sabtu, 16 Januari 2010
Posted in | |
0 Comments »
Breaking News
Mengenai Saya
- Rumah Info
- Bekasi Jaya, Jawa Barat, Indonesia
- saya sudah bersahabat dengan internet beberapa tahun silam
One Responses to "Pascal : ZigZag Checker"