Exercicios Pascal
Autor: Everton Back | Publicado: 2016-04-28T08:55:00-03:00

<!--[if !mso]>

v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}

<![endif]-->
<!--[if gte mso 9]>
 
  
  
 
<![endif]--><!--[if gte mso 9]>
 
  Normal
  0
  
  
  21
  
  
  false
  false
  false
  
  PT-BR
  X-NONE
  X-NONE
  
   
   
   
   
   
   
   
   
   
   
   
  
  
   
   
   
   
   
   
   
   
   
   
   
  
<![endif]--><!--[if gte mso 9]>
 <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
  DefSemiHidden="true" DefQFormat="false" DefPriority="99"
  LatentStyleCount="267">
  <w:LsdException Locked="false" Priority="0" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  <w:LsdException Locked="false" Priority="10" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Title"/>
  
  <w:LsdException Locked="false" Priority="11" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
  <w:LsdException Locked="false" Priority="22" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
  <w:LsdException Locked="false" Priority="20" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
  <w:LsdException Locked="false" Priority="59" SemiHidden="false"
   UnhideWhenUsed="false" Name="Table Grid"/>
  
  <w:LsdException Locked="false" Priority="1" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 1"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
  
  <w:LsdException Locked="false" Priority="34" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
  <w:LsdException Locked="false" Priority="29" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
  <w:LsdException Locked="false" Priority="30" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 1"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 2"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 2"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 3"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 3"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 4"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 4"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 5"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 5"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 6"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 6"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
  <w:LsdException Locked="false" Priority="19" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
  <w:LsdException Locked="false" Priority="21" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
  <w:LsdException Locked="false" Priority="31" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
  <w:LsdException Locked="false" Priority="32" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
  <w:LsdException Locked="false" Priority="33" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
  
  
 
<![endif]--><!--[if gte mso 10]>

 /* Style Definitions */
 table.MsoNormalTable
 {mso-style-name:"Tabela normal";
 mso-tstyle-rowband-size:0;
 mso-tstyle-colband-size:0;
 mso-style-noshow:yes;
 mso-style-priority:99;
 mso-style-qformat:yes;
 mso-style-parent:"";
 mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
 mso-para-margin:0cm;
 mso-para-margin-bottom:.0001pt;
 mso-pagination:widow-orphan;
 font-size:11.0pt;
 font-family:"Calibri","sans-serif";
 mso-ascii-font-family:Calibri;
 mso-ascii-theme-font:minor-latin;
 mso-fareast-font-family:"Times New Roman";
 mso-fareast-theme-font:minor-fareast;
 mso-hansi-font-family:Calibri;
 mso-hansi-theme-font:minor-latin;
 mso-bidi-font-family:"Times New Roman";
 mso-bidi-theme-font:minor-bidi;}

<![endif]-->



Lista de Exercícios (Resolvidos)
- Pascal



1. Escreva um programa em Pascal para ler, calcular e
escrever a média aritmética entre dois números.
program ex1;
uses crt;
&nbsp;
var n1, n2, m: real;
&nbsp;
begin
clrscr;
write('Informe um numero: ');
readln(n1);
write('Informe outro numero: ');
readln(n2);
m:=(n1+n2)/2;
writeln('A media ‚: ',m:0:2);
readkey;
end.
&nbsp;








2. Escreva um programa em Pascal para ler um número
positivo qualquer, calcular e escrever o quadrado e a raiz quadrada do mesmo.
program ex2;
uses crt;
&nbsp;
var x, q: integer;
 r: real;
&nbsp;
begin
clrscr;
write('Informe um numero: ');
readln(x);
q:= sqr(x);
writeln('O quadrado de ', x, ' ‚ ', q);
if x&gt;=0 then
&nbsp;&nbsp; begin
&nbsp;&nbsp; r:= sqrt(x);
&nbsp;&nbsp; writeln('A raiz quadrada de ', x, ' ‚ ', r:0:2);
&nbsp;&nbsp; end
else
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln('Nao existe raiz de ',x);
&nbsp;&nbsp;&nbsp; end;
readkey;
end.
&nbsp;






3. Escrever um programa em Pascal que leia 3 valores: a,
b, c e calcule e escreva a média aritmética, harmônica e geométrica
correspondente.
program ex3;
uses crt;
&nbsp;
var a, b, c, ma, mg, mh: real;
&nbsp;
begin
clrscr;
write('Informe o primeiro numero: ');
readln(a);
write('Informe o segundo numero: ');
readln(b);
write('Informe o terceiro numero: ');
readln(c);
ma:= (a+b+c)/3;
mh:= 3/(1/a + 1/b +1/c);
mg:= exp(ln(a*b*c)*(1/3));
writeln('Media Aritmetica: ',ma:0:2);
writeln('Media Harmonica: ',mh:0:2);
writeln('Media Geometrica: ',mg:0:2);
readkey;
end.
&nbsp;






4. Escrever um programa em Pascal que lê o número de um
funcionário, seu número de horas trabalhadas, o valor que&nbsp; recebe por
hora, e o número de filhos com idade menor do que 14 anos e calcula o salário
deste funcionário.
program ex4;
uses crt;
&nbsp;
var
nf, nfil: integer;
nht, vph, sf, st: real;
&nbsp;
begin
clrscr;
write('Informe o numero do funcionario: ');
readln(nf);
write('Informe o numero de horas trabalhadas: ');
readln(nht);
write('Informe o valor que recebe por hora: ');
readln(vph);
write('Informe o numero de filhos: ');
readln(nfil);
write('Informe o valor do salario familia: ');
readln(sf);
st:= nht * vph + nfil * sf;
writeln('O funcionario ', nf, ' recebe um salario total de R$ ', st:0:2);
readkey;
end.
&nbsp;








5. Escrever um programa em Pascal que lê o número de um
vendedor, o seu salário-fixo, o tota1 de vendas por ele efetuadas e o
percentual que ganha sobre o total de vendas. Calcular o salário tota1 do
vendedor. Escrever número do&nbsp; vendedor e o salário total.
program ex5;
uses crt;
&nbsp;
var
nv: integer;
sf, tv, per, st: real;
&nbsp;
begin
clrscr;
write('Informe o numero do vendedor: ');
readln(nv);
write('Informe o salario fixo: ');
readln(sf);
write('Informe o total de vendas: ');
readln(tv);
write('Informe o percentual sobre as vendas: ');
readln(per);
st:= sf + tv * per / 100;
writeln('O vendedor ', nv, ' recebe um salario total de R$ ', st:0:2);
readkey;
end.
&nbsp;








6. Escrever um programa em Pascal que lê 3 valores a, b,
c que são lados de um triângulo e calcule&nbsp; a área deste triângulo. 
program ex6;
uses crt;
&nbsp;
var a, b, c, s, at: real;
&nbsp;
begin
clrscr;
write('Informe o primeiro numero: ');
readln(a);
write('Informe o segundo numero: ');
readln(b);
write('Informe o terceiro numero: ');
readln(c);
s:= (a+b+c)/2;
at:=sqrt(s*(s-a)*(s-b)*(s-c));
writeln('Area do triangulo: ',at:0:2);
readkey;
end.
&nbsp;








7. Uma revendedora de carros usados paga a seus
funcionários vendedores, um salário fixo por mês, mais uma&nbsp; comissão
também fixa para cada carro vendido e mais 5%&nbsp; do valor das vendas por ele
efetuadas. Escrever um programa em Pascal que lê o número do vendedor, o número
de carros&nbsp; por ele vendidos, o valor tota1 de suas vendas,&nbsp; o&nbsp;
salário fixo e o valor que recebe por carro vendido e calcula o salário mensal
do vendedor, escrevendo-o juntamente com o seu número de identificação.
program ex7;
uses crt;
&nbsp;
var
nv, ncv: integer;
sf, tv, vpcv, st: real;
&nbsp;
begin
clrscr;
write('Informe o numero do vendedor: ');
readln(nv);
write('Informe o numero de carros vendidos: ');
readln(ncv);
write('Informe o total de vendas: ');
readln(tv);
write('Informe o salario fixo: ');
readln(sf);
write('Informe o valor por carro vendido: ');
readln(vpcv);
st:= sf + tv * 5 / 100 + ncv * vpcv;
writeln('O vendedor ', nv, ' recebe um salario total de R$ ', st:0:2);
readkey;
end.
&nbsp;








8. Escrever um programa em Pascal que lê 3
valores&nbsp;&nbsp; a, b, c, e escreva os 3 valores em ordem crescente. 
program ex8;
uses crt;
&nbsp;
var a, b, c, aux: integer;
&nbsp;
begin
clrscr;
write('Informe o primeiro numero: ');
readln(a);
write('Informe o segundo numero: ');
readln(b);
write('Informe o terceiro numero: ');
readln(c);
if a&gt;b then
&nbsp;&nbsp; begin
&nbsp;&nbsp; aux:=a;
&nbsp;&nbsp; a:=b;
&nbsp;&nbsp; b:=aux;
&nbsp;&nbsp; end;
if a&gt;c then
&nbsp;&nbsp; begin
&nbsp;&nbsp; aux:=a;
&nbsp;&nbsp; a:=c;
&nbsp;&nbsp; c:=aux;
&nbsp;&nbsp; end;
if b&gt;c then
&nbsp;&nbsp; begin
&nbsp;&nbsp; aux:=b;
&nbsp;&nbsp; b:=c;
&nbsp;&nbsp; c:=aux;
&nbsp;&nbsp; end;
writeln('Valores em ordem crescente: ', a:6, b:6, c:6);
readkey;
end.
&nbsp;

9.
Escrever um algoritmo/programa em Pascal que lê um conjunto de 4 valores&nbsp;
i, a, b, c, onde i é um valor inteiro e positivo e a, b, c, são quaisquer
valores reais e os escreva. A seguir:
Se i = 1 escrever os 3 valores a, b, c em ordem crescente. 
Se i = 2 escrever os 3 valores a, b, c em ordem decrescente.
Se i = 3 escrever os 3 valores de forma que o maior valor entre a, b, c fica
entre os outros 2.


program ex9;
uses crt;

var i, a, b, c, aux: integer;

begin
clrscr;
write('Informe um valor [1, 2, 3]: ');
readln(i);
write('Informe o primeiro numero: ');
readln(a);
write('Informe o segundo numero: ');
readln(b);
write('Informe o terceiro numero: ');
readln(c);
if a&gt;b then
&nbsp;&nbsp; begin
&nbsp;&nbsp; aux:=a;
&nbsp;&nbsp; a:=b;
&nbsp;&nbsp; b:=aux;
&nbsp;&nbsp; end;
if a&gt;c then
&nbsp;&nbsp; begin
&nbsp;&nbsp; aux:=a;
&nbsp;&nbsp; a:=c;
&nbsp;&nbsp; c:=aux;
&nbsp;&nbsp; end;
if b&gt;c then
&nbsp;&nbsp; begin
&nbsp;&nbsp; aux:=b;
&nbsp;&nbsp; b:=c;
&nbsp;&nbsp; c:=aux;
&nbsp;&nbsp; end;
if i=1 then
&nbsp;&nbsp; begin
&nbsp;&nbsp; writeln('Valores em ordem crescente:
', a:6, b:6, c:6);
&nbsp;&nbsp; end;
if i=2 then
&nbsp;&nbsp; begin
&nbsp;&nbsp; writeln('Valores em ordem decrescente:
', c:6, b:6, a:6);
&nbsp;&nbsp; end;
if i=3 then
&nbsp;&nbsp; begin
&nbsp;&nbsp; writeln('Maior Valor no meio: ', a:6,
c:6, b:6);
&nbsp;&nbsp; end;
readkey;
end.









10.
Escrever um algoritmo/programa em Pascal que lê o número de um vendedor de uma empresa,
seu salário fixo e o total de vendas por ele efetuadas.
Cada vendedor recebe um salário fixo, mais uma comissão proporcional às vendas
por ele efetuadas.
A comissão é de 3% sobre o total de vendas até $ 1.000,00&nbsp; e 5% sobre o
que ultrapassa este valor.
Escrever o número do vendedor, o total de suas vendas,&nbsp; seu salário fixo e
seu salário total.

program ex10;
uses crt;

var
nv: integer;
sf, tv st: real;

begin
clrscr;
write('Informe o numero do vendedor: ');
readln(nv);
write('Informe o total de vendas: ');
readln(tv);
write('Informe o salario fixo: ');
readln(sf);
if tv&lt;=1000 then
&nbsp;&nbsp; begin
&nbsp;&nbsp; st:= sf + tv * 3 / 100;
&nbsp;&nbsp; end
else
&nbsp;&nbsp; begin
&nbsp;&nbsp; st:= sf + (tv-1000) * 5 / 100 + 30;
&nbsp;&nbsp; end;
writeln('O vendedor ', nv, ' recebe um salario total de R$ ', st:0:2);
readkey;
end.







11.
Escrever um algoritmo/programa em Pascal que lê 3 comprimentos de lados a, b, c
e os ordena em ordem decrescente, de modo que o a represente o maior dos 3
lados lidos.
Determine, a seguir, o tipo de triângulo que estes 3 lados formam, com base nos
seguintes casos escrevendo sempre os valores lidos e uma mensagem adequada:
&nbsp;&nbsp;&nbsp; Se a &gt; b + c não formam triângulo algum.
&nbsp;&nbsp;&nbsp; Se a2 = b2 + c2&nbsp; formam um triângulo retângulo.
&nbsp;&nbsp;&nbsp; Se a2 &gt; b2 + c2&nbsp; formam um triângulo obtusângulo.
&nbsp;&nbsp;&nbsp; Se a2 &lt; b2 + c2&nbsp; formam um triângulo acutângulo.
&nbsp;&nbsp;&nbsp; Se forem todos iguais formam um triângulo equilátero.
&nbsp;&nbsp;&nbsp; Se a = b ou b = c ou a = c então formam um triângulo
isósceles

program
ex11;
uses crt;

var a, b, c, aux: integer;

begin
clrscr;
write('Informe o primeiro numero: ');
readln(a);
write('Informe o segundo numero: ');
readln(b);
write('Informe o terceiro numero: ');
readln(c);
if a&lt;b then
&nbsp;&nbsp; begin
&nbsp;&nbsp; aux:=a;
&nbsp;&nbsp; a:=b;
&nbsp;&nbsp; b:=aux;
&nbsp;&nbsp; end;
if a&lt;c then
&nbsp;&nbsp; begin
&nbsp;&nbsp; aux:=a;
&nbsp;&nbsp; a:=c;
&nbsp;&nbsp; c:=aux;
&nbsp;&nbsp; end;
if b&lt;c then
&nbsp;&nbsp; begin
&nbsp;&nbsp; aux:=b;
&nbsp;&nbsp; b:=c;
&nbsp;&nbsp; c:=aux;
&nbsp;&nbsp; end;
if a&gt;b+c then
&nbsp;&nbsp; begin
&nbsp;&nbsp; writeln('Nao forma triangulo.');
&nbsp;&nbsp; end
else
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; if sqr(a) = sqr(b)+sqr(c) then
writeln('Formam um triangulo retangulo.');
&nbsp;&nbsp;&nbsp; if sqr(a) &gt; sqr(b)+sqr(c) then
writeln('Formam um triangulo obtusangulo.');
&nbsp;&nbsp;&nbsp; if sqr(a) &lt; sqr(b)+sqr(c) then
writeln('Formam um triangulo acutangulo.');
&nbsp;&nbsp;&nbsp; if (a=b) and (b=c) then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writeln('Formam um triangulo
equilatero.');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end
&nbsp;&nbsp;&nbsp; else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (a=b) or (a=c) or (b=c) then
writeln('Formam um triangulo isosceles.');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
readkey;
end.









12. Escrever um algoritmo/programa em Pascal que lê
a hora de início de um jogo&nbsp; e a hora do final do jogo (considerando
apenas horas inteiras) e calcula a duração do jogo em horas, sabendo-se que
o&nbsp; tempo máximo de duração do jogo é de 24 horas e que o jogo pode iniciar
em um dia e terminar no dia seguinte.

program ex12;
uses crt;

var
hi, hf, dj: integer;

begin
clrscr;
write('Informe a hora inicial do jogo: ');
readln(hi);
write('Informe a hora final do jogo: ');
readln(hf);
if hf &gt; hi then
&nbsp;&nbsp; begin
&nbsp;&nbsp; dj:=hf - hi;
&nbsp;&nbsp; writeln('O jogo durou ',dj,' horas.');
&nbsp;&nbsp; end
else
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; dj:=hf - hi + 24;
&nbsp;&nbsp;&nbsp; writeln('O jogo durou ',dj,'
horas.');
&nbsp;&nbsp;&nbsp; end;
readkey;
end.









15. A
empresa Enxuga Gelo SA decidiu conceder um aumento de salários&nbsp; a seus
funcionários de acordo com a tabela abaixo:

Salário Atual&nbsp;&nbsp;&nbsp; Índice De Aumento
0 - 400,00&nbsp;&nbsp;&nbsp; 15%
400,01 - 700,00&nbsp;&nbsp;&nbsp; 12%
700,01 - 1.000,00&nbsp;&nbsp;&nbsp; 10%
1.000,01 - 1.800,00&nbsp;&nbsp;&nbsp; 7%
1.800,01 - 2.500,00&nbsp;&nbsp;&nbsp; 4%
acima de 2.500,00&nbsp;&nbsp;&nbsp; sem aumento

Escrever um algoritmo/programa em Pascal que lê, para cada funcionário, o seu
número e o seu salário atual e escreve o numero do funcionário, seu salário
atua1, o percentual de seu aumento e o valor do salário corrigido.

program
ex15;
uses crt;

var
nf: integer;
pa, sc, sa: real;

begin
clrscr;
write('Informe o numero do funcionario: ');
readln(nf);
write('Informe o salario atual: ');
readln(sa);
if sa&lt;=400 then pa:=15;
if (sa&gt;400) and (sa&lt;=700) then pa:=12;
if (sa&gt;700) and (sa&lt;=1000) then pa:=10;
if (sa&gt;1000) and (sa&lt;=1800) then pa:=7;
if (sa&gt;1800) and (sa&lt;=2500) then pa:=4;
if (sa&gt;2500) then pa:=0;
sc:=sa + sa * pa/100;
writeln('Funcionario: ', nf);
writeln('Salario Atual: ',sa:0:2);
writeln('Percentual de Aumento: ',pa:0:2,'%');
writeln('Salario Corrigido: ',sc:0:2);
readkey;
end.
end.



17. Escrever um
algoritmo/programa em Pascal que lê 5 valores para a, um de cada vez, e conta
quantos destes valores são negativos, escrevendo esta informação.


program ex17;
uses crt;

var i, a, cont: integer;

begin
clrscr;
cont:=0;
for i:= 1 to 5 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write('Informe um valor: ');
&nbsp;&nbsp;&nbsp; readln(a);
&nbsp;&nbsp;&nbsp; if a&lt;0 then cont:=cont+1;
&nbsp;&nbsp;&nbsp; end;
writeln('Existem ',cont,' valores negativos.');
readkey;
end. 







18. Escrever um
algoritmo/programa em Pascal que escreve os números pares entre 100 e 200.

program ex18;
uses crt;

var i: integer;

begin
clrscr;
writeln('Os numeros pares de 100 a 200 sao: ');
for i:= 100 to 200 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; if i mod 2 = 0 then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write(i:8);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
readkey;
end.







19. Escrever um
algoritmo/programa em Pascal que escreve a soma dos números entre 0 e 100.

program ex19;
uses crt;

var i, soma: integer;

begin
clrscr;
soma:=0;
for i:= 0 to 100 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; soma:= soma + i;
&nbsp;&nbsp;&nbsp; end;
writeln('A soma dos numeros de 0 a 100 e: ', soma);
readkey;
end.







20. Escrever um
algoritmo/programa em Pascal que escreve a soma dos números pares entre 0 e
100.

program ex20;
uses crt;

var i, soma: integer;

begin
clrscr;
soma:=0;
for i:= 0 to 100 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; if i mod 2 = 0 then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soma:= soma + i;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
writeln('A soma dos numeros pares de 0 a 100 e: ', soma);
readkey;
end.







21. Escrever um
algoritmo/programa em Pascal que escreve a soma dos números múltiplos de 7
entre 100 e 200.


program ex21;
uses crt;

var i, soma: integer;

begin
clrscr;
soma:=0;
for i:= 100 to 200 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; if i mod 7 = 0 then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soma:= soma + i;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
writeln('A soma dos numeros multiplos de 7 de 100 a 200 e: ', soma);
readkey;
end.



22. Escrever um
algoritmo/programa em Pascal que escreve a soma dos números que não são
múltiplos de 13 entre 100 e 200.


program ex22;
uses crt;

var i, soma: integer;

begin
clrscr;
soma:=0;
for i:= 100 to 200 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; if i mod 13 &lt;&gt; 0 then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soma:= soma + i;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
writeln('A soma dos numeros nao multiplos de 13 de 100 a 200 e: ', soma);
readkey;
end.



23. Escrever um
algoritmo/programa em Pascal que lê 20 valores, um de cada vez, e conta quantos
deles estão em&nbsp; cada um dos intervalos&nbsp; [0, 25], (25, 50], (50, 75],
(75, 100], escrevendo esta informação


program ex23;
uses crt;

var i, x, cont1, cont2, cont3, cont4: integer;

begin
clrscr;
cont1:=0; cont2:=0; cont3:=0; cont4:=0;
for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write('Informe um valor (0-100): ');
&nbsp;&nbsp;&nbsp; readln(x);
&nbsp;&nbsp;&nbsp; if (x&gt;=0) and (x&lt;=25)&nbsp; then cont1:=cont1 + 1;
&nbsp;&nbsp;&nbsp; if (x&gt;25) and (x&lt;=50)&nbsp; then cont2:=cont2 + 1;
&nbsp;&nbsp;&nbsp; if (x&gt;50) and (x&lt;=75)&nbsp; then cont3:=cont3 + 1;
&nbsp;&nbsp;&nbsp; if (x&gt;75) and (x&lt;=100) then cont4:=cont4 + 1;
&nbsp;&nbsp;&nbsp; end;
writeln('No intervalo&nbsp; 0 -&nbsp; 25 existem ', cont1, ' numeros.');
writeln('No intervalo 26 -&nbsp; 50 existem ', cont2, ' numeros.');
writeln('No intervalo 51 -&nbsp; 75 existem ', cont3, ' numeros.');
writeln('No intervalo 76 - 100 existem ', cont4, ' numeros.');
readkey;
end.



24. Escrever um
algoritmo/programa em Pascal semelhante ao anterior que calcula as médias
aritméticas de cada intervalo e as escreve, juntamente com o número de valores
de cada intervalo.


program ex24;
uses crt;

var
i, x, cont1, cont2, cont3, cont4, soma1, soma2, soma3, soma4: integer;
m1, m2, m3, m4: real;

begin
clrscr;
cont1:=0; cont2:=0; cont3:=0; cont4:=0;
soma1:=0; soma2:=0; soma3:=0; soma4:=0;

for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write('Informe um valor (0-100): ');
&nbsp;&nbsp;&nbsp; readln(x);
&nbsp;&nbsp;&nbsp; if (x&gt;=0) and (x&lt;=25)&nbsp; then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cont1:=cont1 + 1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soma1:=soma1 + x;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m1:=soma1 / cont1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; if (x&gt;25) and (x&lt;=50)&nbsp; then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cont2:=cont2 + 1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soma2:=soma2 + x;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m2:=soma2 / cont2;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; if (x&gt;50) and (x&lt;=75)&nbsp; then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cont3:=cont3 + 1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soma3:=soma3 + x;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m3:=soma3 / cont3;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; if (x&gt;75) and (x&lt;=100) then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cont4:=cont4 + 1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soma4:=soma4 + x;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m4:=soma4 / cont4;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
writeln('No intervalo&nbsp; 0 -&nbsp; 25 existem ', cont1, ' numeros e a media
e: ', m1:0:2);
writeln('No intervalo 26 -&nbsp; 50 existem ', cont2, ' numeros e a media e: ',
m2:0:2);
writeln('No intervalo 51 -&nbsp; 75 existem ', cont3, ' numeros e a media e: ',
m3:0:2);
writeln('No intervalo 76 - 100 existem ', cont4, ' numeros e a media e: ',
m4:0:2);
readkey;
end.



25. Escrever um
algoritmo/programa em Pascal que lê um número e calcula e escreve quantos
divisores ele possui.


program ex25;
uses crt;

var x, i, cont: integer;

begin
clrscr;
write('Informe um numero: ');
readln(x);
cont:=0;
for i:= 1 to x do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; if x mod i = 0 then cont:=cont + 1;
&nbsp;&nbsp;&nbsp; end;
writeln('O numero ', x, ' possui ', cont, ' divisores.');
readkey;
end.



26. Escrever um
algoritmo/programa em Pascal que lê um número e calcula e escreve o seu
fatorial.


program ex26;
uses crt;

var x, i: integer;
fat: longint;

begin
clrscr;
write('Informe um numero: ');
readln(x);
fat:=1;
for i:= 1 to x do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; fat:=fat * i;
&nbsp;&nbsp;&nbsp; end;
writeln('O fatorial de ', x, ' e: ', fat);
readkey;
end.



27. Escrever um algoritmo/programa
em Pascal que lê um número e escreva se ele "é primo" ou "não é
primo" 


program ex27;
uses crt;

var x, i, cont: integer;

begin
clrscr;
write('Informe um numero: ');
readln(x);
cont:=0;
for i:= 1 to x do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; if x mod i = 0 then cont:=cont + 1;
&nbsp;&nbsp;&nbsp; end;
if cont&lt;=2 then
&nbsp;&nbsp; begin
&nbsp;&nbsp; writeln('O numero ', x, ' e primo.');
&nbsp;&nbsp; end
else
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln('O numero ', x, ' nao e primo.');
&nbsp;&nbsp;&nbsp; end;
readkey;
end.



28. Escrever um
algoritmo/programa em Pascal que escreve os números múltiplos de 7 entre 100 e
200, bem como a soma destes números.


program ex28;
uses crt;

var i, soma: integer;

begin
clrscr;
soma:=0;
writeln('Os numeros multiplos de 7 de 100 a 200 sao:');
for i:= 100 to 200 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; if i mod 7 = 0 then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write(i:8);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soma:= soma + i;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
writeln;
writeln;
writeln('A soma dos numeros multiplos de 7 de 100 a 200 e: ', soma);
readkey;
end.



29. Escrever um
algoritmo/programa em Pascal que lê um número não conhecido de valores, um de
cada vez, e conta quantos deles estão em&nbsp; cada um dos intervalos&nbsp; [0,
50], (50, 100], (100,200]. O programa deve encerrar quando for informado um
valor fora dos intervalos.


Questão do Trabalho. 

30. Escrever um
algoritmo/programa em Pascal que lê um número não determinado de valores para
m, todos inteiros e positivos, um de cada vez. Se m for par, verificar quantos
divisores possui e&nbsp; escrever esta informação. Se m for ímpar e menor do
que 12 calcular e escrever o fatorial de m. Se m for ímpar e maior ou igua1 a
12 calcular e escrever a soma dos inteiros de l até m.


Questão do Trabalho.

31. Escrever um
algoritmo/programa em Pascal que lê um número não determinados de valores a,
todos inteiros e positivos, um de cada vez, e calcule e escreva a média
aritmética dos valores lidos, a quantidade de valores pares, a quantidade de
valores impares, a percentagem de valores pares e a percentagem de valores
ímpares.


Questão do Trabalho.

32. Escrever um
algoritmo/programa em Pascal que escreve os números primos entre 100 e 200, bem
como a soma destes números.


program ex32;
uses crt;

var x, i, cont: integer;

begin
clrscr;
for x:= 100 to 200 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; cont:=0;
&nbsp;&nbsp;&nbsp; for i:= 1 to x do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if x mod i = 0 then cont:=cont + 1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; if cont&lt;=2 then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writeln('O numero ', x, ' e primo.');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
readkey;
end.



33. Escrever um
algoritmo/programa em Pascal que lê 5 conjuntos de 4 valores a, b, c, d, um
conjunto por vez e os escreve assim como foram lidos. Em seguida, ordene-os em
ordem decrescente e escreva-os novamente.


program ex33;
uses crt;

var i, a, b, c, d, aux: integer;

begin
clrscr;
for i:= 1 to 5 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write('Informe um valor: ');
&nbsp;&nbsp;&nbsp; readln(a);
&nbsp;&nbsp;&nbsp; write('Informe um valor: ');
&nbsp;&nbsp;&nbsp; readln(b);
&nbsp;&nbsp;&nbsp; write('Informe um valor: ');
&nbsp;&nbsp;&nbsp; readln(c);
&nbsp;&nbsp;&nbsp; write('Informe um valor: ');
&nbsp;&nbsp;&nbsp; readln(d);
&nbsp;&nbsp;&nbsp; writeln('Numeros digitados:&nbsp;&nbsp;&nbsp; ', a:6, b:6,
c:6, d:6);
&nbsp;&nbsp;&nbsp; if a&lt;b then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aux := a;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a&nbsp;&nbsp; := b;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b&nbsp;&nbsp; := aux;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; if a&lt;c then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aux := a;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a&nbsp;&nbsp; := c;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c&nbsp;&nbsp; := aux;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; if a&lt;d then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aux := a;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a&nbsp;&nbsp; := d;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d&nbsp;&nbsp; := aux;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; if b&lt;c then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aux := b;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b&nbsp;&nbsp; := c;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c&nbsp;&nbsp; := aux;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; if b&lt;d then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aux := b;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b&nbsp;&nbsp; := d;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d&nbsp;&nbsp; := aux;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; if c&lt;d then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aux := c;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c&nbsp;&nbsp; := d;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d&nbsp;&nbsp; := aux;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; writeln('Em ordem decrescente: ', a:6, b:6, c:6, d:6);
&nbsp;&nbsp;&nbsp; readkey;
&nbsp;&nbsp;&nbsp; end;
end.



34. Escrever um
algoritmo/programa em Pascal que lê 10 valores para n, um de cada vez, todos
inteiros e positivos, e para cada n lido, escreva a tabuada de 1 até n de n. 


program ex34;
uses crt;

var i, j, n: integer;

begin
clrscr;
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write('Informe um n£mero: ');
&nbsp;&nbsp;&nbsp; readln(n);
&nbsp;&nbsp;&nbsp; for j:= 1 to n do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writeln(j, ' x ', n, ' = ', j * n);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
readkey;
end.



35. Escrever um
algoritmo/programa em Pascal que lê 5 pares de valores a, b,&nbsp; todos
inteiros e positivos, um par de cada vez, e com a &lt; b, e escreve os inteiros
pares de a até b, incluindo o a e b se forem pares.


program ex35;
uses crt;

var i, j, a, b, aux: integer;

begin
clrscr;
for i:= 1 to 5 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write('Informe um n£mero: ');
&nbsp;&nbsp;&nbsp; readln(a);
&nbsp;&nbsp;&nbsp; write('Informe um n£mero: ');
&nbsp;&nbsp;&nbsp; readln(b);
&nbsp;&nbsp;&nbsp; if a&gt;b then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aux:=a;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a:=b;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b:=aux;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; for j:= a to b do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if j mod 2 = 0 then writeln(j);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
readkey;
end.



36. A série de Fibonacci tem como
dados os 2 primeiros&nbsp; termos da série que são respectivamente 0 e 1. A
partir deles, os demais termos são construídos pela seguinte regra: tn = tn-1 +
tn-2. Escrever um algoritmo/programa em Pascal que gera os 10 primeiros termos
da Série de Fibonacci e calcula&nbsp; e escreve a soma destes termos.


program ex36;
uses crt;

var ult, pen, nt, i: integer;

begin
clrscr;
writeln('Termos Serie Fibonacci:');
pen:=0;
ult:=1;
writeln(pen);
writeln(ult);
for i:= 1 to 8 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; nt:=ult + pen;
&nbsp;&nbsp;&nbsp; writeln(nt);
&nbsp;&nbsp;&nbsp; pen:=ult;
&nbsp;&nbsp;&nbsp; ult:=nt;
&nbsp;&nbsp;&nbsp; end;
readkey;
end.



39. Escrever um
algoritmo/programa em Pascal que lê 5 conjuntos de 2 valores, o primeiro
representando o número de um aluno e o segundo representando a sua altura em
centímetros. Encontrar o aluno mais alto e o mais baixo e escrever seus
números, suas alturas e uma mensagem dizendo se é o mais alto ou o mais baixo.


Questão do Trabalho.

40. Escrever um
algoritmo/programa em Pascal que gera e escreve os 5 primeiros números
perfeitos. Um número perfeito é aquele que é igual a soma dos seus divisores. (Ex.: 6 = l + 2 + 3; 28 = 1 + 2 + 4 + 7 + 14 etc.).


program ex40;
uses crt;

var cont, x, soma, i: integer;

begin
clrscr;
cont:=0;
x:=0;
writeln('Os numeros perfeitos sao: ');
repeat
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x:=x+1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soma:=0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for i:= 1 to x-1 do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if x mod i = 0 then
soma:=soma + i;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if soma = x then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writeln(x);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cont:=cont+1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end
until cont=4;
writeln('Pressione qualquer tecla para finalizar...');
readkey;
end.



41. Escrever um
algoritmo/programa em Pascal que lê 50 valores, um de cada vez, e encontra e
escreve o maior deles.


program ex41;
uses crt;

var i, x, m: integer;

begin
clrscr;
for i:= 1 to 50 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write('Informe o ',i,'.o valor: ');
&nbsp;&nbsp;&nbsp; readln(x);
&nbsp;&nbsp;&nbsp; if i=1 then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m:=x;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; if x &gt; m then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m:=x;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
writeln('O maior valor e: ', m);
readkey;
end.



42. Escrever um
algoritmo/programa em Pascal que gera os números de 1000 a 1999 e escreve
aqueles que divididos por 11 dão um resto igual a 5.


program ex42;
uses crt;

var
i: integer;
begin
clrscr;
for i:= 1000 to 1999 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; if i mod 11 = 5 then write(i:8);
&nbsp;&nbsp;&nbsp; end;
readkey;
end.



43. Escrever um
algoritmo/programa em Pascal que lê um valor N e calcula e escreve os 20
primeiros termos da série: 1 + 1/x2&nbsp; + 1/x3 + 1/x4 + ...


program ex43;
uses crt;

var
x, i: integer;
t, soma: real;
begin
clrscr;
soma:=0;
write('Informe um valor: ');
readln(x);
writeln('Termos:');
t:=1;
writeln(t:0:8);
soma:=soma+t;
for i:= 2 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; t:= 1/ (exp(ln(x)*i));
&nbsp;&nbsp;&nbsp; writeln(t:0:8);
&nbsp;&nbsp;&nbsp; soma:=soma+t;
&nbsp;&nbsp;&nbsp; end;
writeln('A soma e: ', soma:0:8);
readkey;
end.



44. Escrever um
algoritmo/programa em Pascal que calcula e escreve o&nbsp; produto dos números
primos entre 92 e 1478.


Questão do Trabalho.

45. Escrever um
algoritmo/programa em Pascal que lê N, inteiro e positivo e calcula e escreve o
termo de ordem N da sucessão abaixo: ordem: &nbsp;&nbsp;&nbsp;
&nbsp;1&nbsp;&nbsp; &nbsp;2&nbsp;&nbsp; &nbsp;3&nbsp;&nbsp; &nbsp;4&nbsp;&nbsp;
&nbsp;5&nbsp;&nbsp; &nbsp;6&nbsp;&nbsp; &nbsp;7&nbsp;&nbsp; &nbsp;8 ...
sucessão: &nbsp;&nbsp; &nbsp;-1&nbsp;&nbsp; &nbsp;0&nbsp;&nbsp;
&nbsp;5&nbsp;&nbsp; &nbsp;6&nbsp;&nbsp; &nbsp;11&nbsp;&nbsp;
&nbsp;12&nbsp;&nbsp; &nbsp;17&nbsp;&nbsp; &nbsp;18 ...


program ex45;
uses crt;

var x, i, nro: integer;
begin
clrscr;
write('Informe um numero: ');
readln(x);
nro:=-1;
for i:= 1 to x do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write(nro:4);
&nbsp;&nbsp;&nbsp; if i mod 2 &lt;&gt; 0 then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nro:=nro+1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end
&nbsp;&nbsp;&nbsp; else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nro:=nro+5;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
readkey;
end.


47.Escrever um algoritmo/programa em Pascal que lê um vetor V[6] e o escreve. Conte, a seguir quantos valores de V são negativos e escreva esta informação.
&nbsp;
program ex47;
uses crt;
var v: array[1..6] of integer;
i, cont: integer;
begin
clrscr;
for i:= 1 to 6 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln('Informe o ', i ,'§ valor: ');
&nbsp;&nbsp;&nbsp; readln(v[i]);
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 6 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln(v[i]);
&nbsp;&nbsp;&nbsp; end;
cont:=0;
for i:= 1 to 6 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; if v[i]&lt;0 then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cont:=cont+1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
writeln('Existem ',cont,' valores negativos.');
readkey;
end.
&nbsp;
48. Escrever um algoritmo/programa em Pascal que lê um vetor X(100) e o&nbsp; escreve. Substitua, a seguir, todos os valores nulos de X por 1&nbsp;&nbsp; e escreva novamente o vetor&nbsp; x
&nbsp;
program ex48;
uses crt;
var
x: array[1..100] of integer;
i: integer;
begin
clrscr;
for i:= 1 to 100 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln('Informe o ', i ,'§ valor: ');
&nbsp;&nbsp;&nbsp; readln(x[i]);
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 100 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln(x[i]);
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 100 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; if x[i]=0 then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x[i]:=1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 100 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln(x[i]);
&nbsp;&nbsp;&nbsp; end;
readkey;
end.
&nbsp;
&nbsp;
&nbsp;
49. Escrever um algoritmo/programa em Pascal que lê um vetor C[50] e o escreve. Encontre, a seguir, o maior elemento de C e o escreva.
&nbsp;
program ex49;
uses crt;
var
c: array[1..50] of integer;
m, i: integer;
begin
clrscr;
for i:= 1 to 50 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln('Informe o ', i ,'§ valor: ');
&nbsp;&nbsp;&nbsp; readln(c[i]);
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 50 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln(c[i]);
&nbsp;&nbsp;&nbsp; end;
m:=c[1];
for i:= 1 to 50 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; if c[i]&gt;m then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m:=c[i];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
writeln('O maior valor e: ', m);
readkey;
end.
&nbsp;
&nbsp;
50. Escrever um algoritmo/programa em Pascal que lê um vetor N[80] e o escreve. Encontre, a seguir, o menor elemento e a sua posição no vetor N e escreva: "o menor elemento de n é = ",&nbsp; M, "e a sua posição é = ", P.
&nbsp;
program ex50;
uses crt;
var
n: array[1..80] of integer;
m, p, i: integer;
begin
clrscr;
for i:= 1 to 80 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln('Informe o ', i ,'§ valor: ');
&nbsp;&nbsp;&nbsp; readln(n[i]);
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 80 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln(n[i]);
&nbsp;&nbsp;&nbsp; end;
m:=n[1];
p:=1;
for i:= 1 to 80 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; if n[i]&lt;m then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m:=n[i];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p:=i;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
writeln('O menor valor e: ', m, ' e esta na posicao ', p);
readkey;
end.
&nbsp;
&nbsp;
&nbsp;
51. Escrever um a1goritmo que lê um vetor A[15] e o escreve. Ordene, a seguir os elementos de A em ordem crescente e escreva novamente A.
&nbsp;
program ex51;
uses crt;
var
a: array[1..15] of integer;
aux, j, i: integer;
begin
clrscr;
for i:= 1 to 15 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln('Informe o ', i ,'§ valor: ');
&nbsp;&nbsp;&nbsp; readln(a[i]);
&nbsp;&nbsp;&nbsp; end;
writeln('Vetor original: ');
for i:= 1 to 15 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write(a[i]:5);
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 14 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; for j:= i+1 to 15 do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if a[i]&gt;a[j] then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aux:=a[i];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a[i]:=a[j];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a[j]:=aux;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
writeln;
writeln('Vetor em ordem crescente: ');
for i:= 1 to 15 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write(a[i]:5);
&nbsp;&nbsp;&nbsp; end;
readkey;
end.
&nbsp;
&nbsp;
52. Escrever um algoritmo/programa em Pascal que lê um vetor N[20] e o escreve. Troque, a seguir, o 1º elemento com o último, o 2º com&nbsp; o penúltimo, etc., até o 10º com o 11º e escreva o vetor N assim modificado.
&nbsp;
program ex52;
uses crt;
var
n: array[1..20] of integer;
aux, i: integer;
begin
clrscr;
for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln('Informe o ', i ,'§ valor: ');
&nbsp;&nbsp;&nbsp; readln(n[i]);
&nbsp;&nbsp;&nbsp; end;
writeln('Vetor original: ');
for i:= 1 to 20 do
&nbsp;&nbsp; &nbsp;begin
&nbsp;&nbsp;&nbsp; write(n[i]:5);
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; aux:=n[i];
&nbsp;&nbsp;&nbsp; n[i]:=n[21-i];
&nbsp;&nbsp;&nbsp; n[21-i]:=aux;
&nbsp;&nbsp;&nbsp; end;
writeln;
writeln('Vetor alterado: ');
for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write(n[i]:5);
&nbsp;&nbsp;&nbsp; end;
readkey;
end.
&nbsp;
&nbsp;
53. Escrever um algoritmo/programa em Pascal que lê um vetor K(20) e o escreve. Troque, a seguir, os elementos de ordem ímpar com os de ordem par imediatamente seguintes e escreva o vetor k modificado.
&nbsp;
program ex53;
uses crt;
var
k: array[1..20] of integer;
aux, i: integer;
begin
clrscr;
for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln('Informe o ', i ,'§ valor: ');
&nbsp;&nbsp;&nbsp; readln(k[i]);
&nbsp;&nbsp;&nbsp; end;
writeln('Vetor original: ');
for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write(k[i]:5);
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; if i mod 2&lt;&gt;0 then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aux:=k[i];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k[i]:=k[i+1];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k[i+1]:=aux;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
writeln;
writeln('Vetor alterado: ');
for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write(k[i]:5);
&nbsp;&nbsp;&nbsp; end;
readkey;
end.
&nbsp;
&nbsp;
54. Escrever um algoritmo/programa em Pascal que lê um vetor N[20] e o escreve. Troque, a seguir, o 1º elemento com 11º, o 2º com o 12º, etc., até o 10º com o 20º e escreva o vetor assim modificado.
&nbsp;
program ex54;
uses crt;
var
n: array[1..20] of integer;
aux, i: integer;
begin
clrscr;
for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln('Informe o ', i ,'§ valor: ');
&nbsp;&nbsp;&nbsp; readln(n[i]);
&nbsp;&nbsp;&nbsp; end;
writeln('Vetor original: ');
for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write(n[i]:5);
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; aux:=n[i];
&nbsp;&nbsp;&nbsp; n[i]:=n[10+i];
&nbsp;&nbsp;&nbsp; n[10+i]:=aux;
&nbsp;&nbsp;&nbsp; end;
writeln;
writeln('Vetor alterado: ');
for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write(n[i]:5);
&nbsp;&nbsp;&nbsp; end;
readkey;
end.
&nbsp;
&nbsp;
55. Escrever um algoritmo/programa em Pascal que lê um vetor G[20] (gabarito) e a seguir lê um número não determinado de números de alunos e vetores R[20] (resposta), um número e um vetor R de cada vez. O número representa o número de um aluno e o vetor R representa o conjunto de respostas daquele aluno. Para cada aluno calcular o nº de acertos e ca1cular a nota.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nota = número de acertos * 0.5
Escrever o&nbsp; nº do aluno, sua nota e a mensagem "aprovado" se tiver nota maior ou igual a 5 ou "reprovado" se a nota for menor do que 5.
&nbsp;
program ex55;
uses crt;
var
g, r:array[1..20] of integer;
numal, acertos, i: integer;
nota: real;
&nbsp;
begin
clrscr;
writeln('Informe o Gabarito: ');
for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write('Resposta ',i,': ');
&nbsp;&nbsp;&nbsp; readln(g[i]);
&nbsp;&nbsp;&nbsp; end;
repeat
clrscr;
writeln('Informe o Numero do Aluno (0 para sair): ');
readln(numal);
if numal&gt;0 then
&nbsp;&nbsp; begin
&nbsp;&nbsp; writeln('Informe as respostas do aluno ',numal);
&nbsp;&nbsp; for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write('Resposta ',i,': ');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; readln(r[i]);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp; acertos:=0;
&nbsp;&nbsp; for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if r[i]=g[i] then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acertos:=acertos+1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp; nota:=acertos * 0.5;
&nbsp;&nbsp; writeln('O aluno ', numal, ' obteve a nota ', nota:0:1);
&nbsp;&nbsp; if nota&gt;=5 then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writeln('Esta aprovado!')
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end
&nbsp;&nbsp; else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writeln('Esta reprovado!');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp; readkey;
&nbsp;&nbsp; end;
until&nbsp; numal=0;
end.
&nbsp;
&nbsp;
56. Escrever um algoritmo/programa em Pascal que lê 2 vetores K[10] e N[10] e os escreve. Crie, a seguir, um vetor M que seja a diferença entre K e N (M = K - N) e escreva o vetor M.
&nbsp;
program ex56;
uses crt;
var
k, n, m: array[1..10] of integer;
i: integer;
begin
clrscr;
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln('Informe o ', i ,'§ valor do vetor N: ');
&nbsp;&nbsp;&nbsp; readln(n[i]);
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln('Informe o ', i ,'§ valor do vetor K: ');
&nbsp;&nbsp;&nbsp; readln(k[i]);
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; m[i]:=k[i]-n[i];
&nbsp;&nbsp;&nbsp; end;
writeln('Vetor N: ');
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write(n[i]:5);
&nbsp;&nbsp;&nbsp; end;
writeln;
writeln('Vetor K: ');
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write(k[i]:5);
&nbsp;&nbsp;&nbsp; end;
writeln;
writeln('Vetor M: ');
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write(m[i]:5);
&nbsp;&nbsp;&nbsp; end;
readkey;
end.
&nbsp;
&nbsp;
57. Escrever um algoritmo/programa em Pascal que lê um vetor G[13] que é o Gabarito de um teste da loteria esportiva, contendo os valores 1 (coluna 1), 2(coluna 2), e 3 (coluna do meio). Ler, a&nbsp;&nbsp; seguir, para cada apostador, o nº de seu cartão e um vetor Resposta R[13]. Verificar para cada apostador o nº de acertos e escrever o nº do apostador e seu número de&nbsp; acertos. Se&nbsp; tiver 13 acertos, acrescentar a mensagem: "ganhador, parabéns!".
&nbsp;
program ex57;
uses crt;
var
g, r:array[1..13] of integer;
numcart, acertos, i: integer;
&nbsp;
begin
clrscr;
writeln('Informe o Resultado da Loteria (Gabarito): ');
for i:= 1 to 13 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write('Jogo ',i,': ');
&nbsp;&nbsp;&nbsp; readln(g[i]);
&nbsp;&nbsp;&nbsp; end;
repeat
clrscr;
writeln('Informe o Numero do Cartao (0 para sair): ');
readln(numcart);
if numcart&gt;0 then
&nbsp;&nbsp; begin
&nbsp;&nbsp; writeln('Informe as respostas do cartao ',numcart);
&nbsp;&nbsp; for i:= 1 to 13 do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write('Jogo ',i,': ');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; readln(r[i]);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp; acertos:=0;
&nbsp;&nbsp; for i:= 1 to 13 do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if r[i]=g[i] then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acertos:=acertos+1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp; writeln('O cartao ', numcart, ' obteve ', acertos,' acertos!');
&nbsp;&nbsp; if acertos=13 then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writeln('Ganhador, Parabens!')
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp; readkey;
&nbsp;&nbsp; end;
until&nbsp; numcart=0;
end.
&nbsp;
&nbsp;
58. Escrever um algoritmo/programa em Pascal que lê, um vetor V[20] e o escreve. Compacte, a seguir, o vetor Y, retirando dele todos os valores nulos ou negativos e escreva o vetor compactado.
&nbsp;
program ex58;
uses crt;
var
v, y: array[1..20] of integer;
cont, i: integer;
begin
clrscr;
for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln('Informe o ',i, '§ valor: ');
&nbsp;&nbsp;&nbsp; readln(v[i]);
&nbsp;&nbsp;&nbsp; end;
cont:=0;
for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; if v[i]&gt;0 then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cont:=cont+1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; y[cont]:=v[i];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
clrscr;
writeln('Vetor original:');
for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write(v[i]:5);
&nbsp;&nbsp;&nbsp; end;
writeln;
writeln('Vetor compactado: ');
for i:= 1 to cont do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write(y[i]:5);
&nbsp;&nbsp;&nbsp; end;
readkey;
end.
&nbsp;
&nbsp;
59. Escrever um algoritmo/programa em Pascal que lê um vetor V(20) e o escreve. Retire, a seguir, os elementos em duplicata, compactando o vetor Y, e escrevendo o vetor compactado.
&nbsp;
program ex59;
uses crt;
var
v, y: array[1..20] of integer;
contpos,cont, i, j: integer;
begin
clrscr;
for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln('Informe o ',i, '§ valor: ');
&nbsp;&nbsp;&nbsp; readln(v[i]);
&nbsp;&nbsp;&nbsp; end;
contpos:=0;
for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp; &nbsp;&nbsp;cont:=0;
&nbsp;&nbsp;&nbsp; for j:=1 to contpos do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if y[j]=v[i] then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cont:=cont+1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; if cont=0 then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contpos:=contpos+1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; y[contpos]:=v[i];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
clrscr;
writeln('Vetor original:');
for i:= 1 to 20 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write(v[i]:5);
&nbsp;&nbsp;&nbsp; end;
writeln;
writeln('Vetor compactado: ');
for i:= 1 to contpos do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write(y[i]:5);
&nbsp;&nbsp;&nbsp; end;
readkey;
end.
&nbsp;
&nbsp;
61. Escrever um algoritmo/programa em Pascal que lê o 1º termo e a razão de uma progressão aritmética e gera os vinte termos seguintes desta progressão, armazenando-os em 2 vetores de 10 elementos cada, no 1º os termos de ordem ímpar de geração e no 2º os de ordem par de geração. Escreva a seguir os 2 vetores&nbsp; de forma que os termos apareçam na ordem em que foram gerados.
&nbsp;
program ex61;
uses crt;
var
vpar, vimpar: array[1..10] of integer;
t1, r, x, i: integer;
begin
clrscr;
writeln('1.o termo: ');
readln(t1);
writeln('Razao: ');
readln(r);
x:=t1;
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; vimpar[i]:=x;
&nbsp;&nbsp;&nbsp; x:=x+r;
&nbsp;&nbsp;&nbsp; vpar[i]:=x;
&nbsp;&nbsp;&nbsp; x:=x+r;
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; write(vimpar[i]:5, vpar[i]:5);
&nbsp;&nbsp;&nbsp; end;
readkey;
end.
&nbsp;
&nbsp;
62. Escrever um algoritmo/programa em Pascal que gera os 10 primeiros números primos acima de 100 e os armazena em um vetor X(10) escrevendo, no final, o vetor X.
&nbsp;
program ex62;
uses crt;
var
x: array[1..10] of integer;
i, num, contdiv, contprimo: integer;
begin
clrscr;
contprimo:=0;
num:=100;
repeat
num:=num+1;
contdiv:=0;
for i:= 1 to num do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; if num mod i=0 then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contdiv:=contdiv+1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
if contdiv&lt;=2 then
&nbsp;&nbsp; begin
&nbsp;&nbsp; contprimo:=contprimo+1;
&nbsp;&nbsp; x[contprimo]:=num;
&nbsp;&nbsp; end;
until contprimo=10;
writeln('Os numeros primos sao: ');
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; writeln(x[i]);
&nbsp;&nbsp;&nbsp; end;
readkey;
end.
&nbsp;
&nbsp;
63. Escreva um algoritmo/programa em Pascal que lê uma matriz M(5,5) e calcula as somas:
a) da linha 4 de M
b) da coluna 2 de M
c) da diagonal principal
d) da diagonal secundária
e) de todos os elementos da matriz
Escreva estas somas e a matriz.
&nbsp;
program ex63;
uses crt;
var
m: array[1..5,1..5] of integer;
i, j, sl4, sc2, sdp, sds, soma: integer;
begin
sl4:=0; sc2:=0;
sdp:=0; sds:=0;
soma:=0;
clrscr;
writeln('Informe a matriz: ');
for i:= 1 to 5 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; for j:= 1 to 5 do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gotoxy(j*6,i+1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; readln(m[i,j]);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
clrscr;
writeln('Matriz: ');
for i:= 1 to 5 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; for j:= 1 to 5 do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gotoxy(j*6,i+1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write(m[i,j]:6);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
for j:= 1 to 5 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; sl4:=sl4+m[4,j];
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 5 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; sc2:=sc2+m[i,2];
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 5 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; sdp:=sdp+m[i,i];
&nbsp;&nbsp;&nbsp; sds:=sds+m[i,6-i];
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 5 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; for j:= 1 to 5 do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soma:=soma+m[i,j];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
writeln;
writeln('Soma linha 4: ',sl4);
writeln('Soma coluna 2: ',sc2);
writeln('Soma diagonal principal: ',sdp);
writeln('Soma diagonal secundaria: ',sds);
writeln('Soma de toda matriz: ',soma);
readkey;
end.
&nbsp;
64. Escrever um algoritmo/programa em Pascal que lê uma matriz M(6,6) e calcula as somas das partes hachuriadas.
&nbsp;
x X X X X X&nbsp;&nbsp;&nbsp;&nbsp; X X X X X x&nbsp;&nbsp;&nbsp;&nbsp; x X X X X x&nbsp;&nbsp;&nbsp;&nbsp; x x x x x x
x x X X X X&nbsp;&nbsp;&nbsp;&nbsp; X X X X x x&nbsp;&nbsp;&nbsp;&nbsp; x x X X x x&nbsp;&nbsp;&nbsp;&nbsp; X x x x x x
x x x X X X&nbsp;&nbsp;&nbsp;&nbsp; X X X x x x&nbsp;&nbsp;&nbsp;&nbsp; x x x x x x&nbsp;&nbsp;&nbsp;&nbsp; X X x x x x
x x x x X X&nbsp;&nbsp;&nbsp;&nbsp; X X x x x x&nbsp;&nbsp;&nbsp;&nbsp; x x x x x x&nbsp;&nbsp;&nbsp;&nbsp; X X x x x x
x x x x x X&nbsp;&nbsp;&nbsp;&nbsp; X x x x x x&nbsp;&nbsp;&nbsp;&nbsp; x x x x x x&nbsp;&nbsp;&nbsp;&nbsp; X x x x x x
x x x x x x&nbsp;&nbsp;&nbsp;&nbsp; x x x x x x&nbsp;&nbsp;&nbsp;&nbsp; x x x x x x&nbsp;&nbsp;&nbsp;&nbsp; x x x x x x
&nbsp;
Escrever a matriz M e as somas calculadas
&nbsp;
65. Escrever um algoritmo/programa em Pascal que lê uma matriz M(10,10) e a escreve. Troque, a seguir:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - a linha 2 com a linha 8.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - a coluna 4 com a coluna 10
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - a diagonal principal com a secundária 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - a linha 5 com a coluna 10
Escreva a matriz assim modificada.
&nbsp;
program ex65;
uses crt;
var
m: array[1..10,1..10] of integer;
aux, i, j: integer;
begin
clrscr;
writeln('Informe a matriz: ');
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; for j:= 1 to 10 do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gotoxy(j*6,i+1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {readln(m[i,j]);}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m[i,j]:=(i-1)*10+j;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
clrscr;
writeln('Matriz: ');
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; for j:= 1 to 10 do
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gotoxy(j*6,i+1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write(m[i,j]:6);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
readkey;
clrscr;
writeln('Troca da linha 2 com a linha 8:');
for j:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; aux:=m[2,j];
&nbsp;&nbsp;&nbsp; m[2,j]:=m[8,j];
&nbsp;&nbsp;&nbsp; m[8,j]:=aux;
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; for j:= 1 to 10 do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gotoxy(j*6,i+1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write(m[i,j]:6);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
readkey;
clrscr;
writeln('Troca da coluna 4 com a coluna 10:');
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; aux:=m[i,4];
&nbsp;&nbsp;&nbsp; m[i,4]:=m[i,10];
&nbsp;&nbsp;&nbsp; m[i,10]:=aux;
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; for j:= 1 to 10 do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gotoxy(j*6,i+1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write(m[i,j]:6);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
readkey;
clrscr;
writeln('Troca da diagonal principal com a secundaria:');
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; aux:=m[i,i];
&nbsp;&nbsp;&nbsp; m[i,i]:=m[i,11-i];
&nbsp;&nbsp;&nbsp; m[i,11-i]:=aux;
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; for j:= 1 to 10 do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gotoxy(j*6,i+1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write(m[i,j]:6);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
readkey;
clrscr;
writeln('Troca da linha 5 com a coluna 10:');
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; aux:=m[5,i];
&nbsp;&nbsp;&nbsp; m[5,i]:=m[i,10];
&nbsp;&nbsp;&nbsp; m[i,10]:=aux;
&nbsp;&nbsp;&nbsp; end;
for i:= 1 to 10 do
&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp; for j:= 1 to 10 do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gotoxy(j*6,i+1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write(m[i,j]:6);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;
&nbsp;&nbsp;&nbsp; end;
readkey;
end.
&nbsp;