sábado, 3 de setembro de 2011

Exercício com Vetores


O usuário informa 2 vetores (a e b)
Montar o vetor c "oscilando" entre o vetor (a e b).
conforme abaixo

VETOR a
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
VETOR b
11, 12, 13, 14, 15, 16, 17, 18, 19, 20

tendo como resposta o
VETOR c
1, 11, 2, 12, 3, 13, 4, 14...
------------------------------------------------

Program Ex7 ;
Var
a,b:array [1..10] of integer;
c:array [1..20] of integer;
i,j:integer;
Begin
for i:=1 to 10do
begin
writeln('informe o vetor1 V[',i,']:');
readln(a[i]);
end;
for i:=1 to 10 do
begin
writeln('informe o vetor2 V[',i,']:');
readln(b[i]);
end;
j:=1;
for i:=1 to 10 do
begin
c[j]:=a[i];
j:=j+2;
end;
j:=2;
for i:=1 to 10 do
begin
c[j]:=b[i];
j:=j+2;
end;
for i:=1 to 20 do
begin
write(c[i],' ');
end;
End.