segunda-feira, 6 de outubro de 2014

Exercicio Desenho com Matriz Função For

         *          *****             **
       **            ****           ****
     ***              ***          *****
   ****                **         ******
 *****                  *       ********

    1                   2               3


program  ExercicioDesenhoFinal;
uses crt;
var
  opcao  :   integer;
  i      :   integer;
  j      :   integer;
  n      :   integer;
  rep    :   string[5];
begin
  begin
  repeat
   begin
  writeln('Menu');
  writeln('1 - Opcao ');
  writeln('2 - Opcao ');
  writeln('3 - Opcao ');
  write('Digite Opcao de 1 a 3 : ');
  read(opcao);

  if (opcao < 1) or (opcao > 3) then
   begin
   writeln();
   Writeln('Atencao Escolha Opcao 1,2 ou 3');
    end;
   case opcao of

       2:
       begin
 write('digiete quantidade de linha: ');
 read(n);
 writeln();
 for i := 1 to n  do
            begin
            for j := i to n do
            begin
            write(' ');
            end;
  for j :=1  to i  do
           begin
           write('*');
           end;

  writeln();
  end;
end;

    1:
     begin
 write('digiete quantidade de linha: ');
 read(n);
 writeln();

 for i := 1 to n  do
  begin
  write(' ');
     for j :=1  to i do
     begin
          write('*');
     end;
  writeln();
  end;
end;

   3:
  begin
write('digiete quantidade de linha: ');
read(n);
writeln();
for i := 1 to n  do
           begin
   for j := i to n do
   begin
   write(' ');
   end;
        for j :=1  to (2*i)-1  do
          begin
          write('*');
          end;

 writeln();
 end;
end;
end;


   end;


    writeln();
    write('Deseja Continuar (SIM/NAO)');
    read(rep);
    writeln();

     until rep = 'NAO';
   end;

   readkey;
end.         

terça-feira, 30 de setembro de 2014

Exercicio_classe_repeat_until "Corrida Carro"





program Exercicio_classe_repeat_until;
     uses crt;
var
  batmovel : integer;
  mach5 : integer;
  herbie : integer;
  christine : integer;
  turnos : integer;

begin
  randomize();
  writeln('Turnos   batmovel   marchs   herbie   christine');
    REPEAT
          turnos := turnos + 1;
          batmovel := batmovel + (random(100) + 1);
          mach5:= mach5 + (random(100) + 1);
          herbie := herbie + (random(100) + 1);
          christine := christine + (random(100) + 1);
          writeln(turnos:4, '     ',batmovel:4,'       ',mach5:4,'    ',herbie:4, '      ',christine:4,'    ');

    until (batmovel > 1000)or(mach5 > 1000) or (herbie > 1000)or(christine > 1000) ;
          if (batmovel > mach5) and (batmovel > herbie) and (batmovel > christine) then
             writeln('Batmovel ganhou');
          if (mach5 > batmovel) and (mach5 > herbie) and (mach5 > christine) then
             writeln('mach5 ganhou');
          if (herbie > batmovel) and (herbie > mach5) and (herbie > christine) then
             writeln('herbie ganhou');
          if (christine > batmovel) and (christine > herbie) and (christine > mach5) then
             writeln('christine ganhou');
    readkey;
end.             

segunda-feira, 29 de setembro de 2014

Exercico 4 da Prova





program CorrecaoNava4;
uses crt;
var
  i          : integer;
  s          : real;
  n          : integer;
begin
  writeln('Digite o Valor: ');
  readln(n);

  for i:= 1 to n do
      s   :=  s +  (i / ((i-1) + i));
  writeln(' O valor de s ', n, ' eh ', s:0:2);



  readkey;
end.
                           

Exemplo While Jogo de Numero Função Random()





program ExemploWhile;
var
  numero   : integer;
  contador : integer;
  alvo     : integer;
  jogar    : char;

begin
     jogar := 'S';
     randomize();
     while(jogar = 'S')do

     begin
     contador :=0;
     alvo := random(10);
     while(numero <> alvo) do

     begin
     write('Digite um Numero: ');
     readln(numero);
     contador := contador + 1;
     end;
     writeln(' Voce acertou em ' , contador , ' tentativas');
     write(' Quer jogar Novamente (S/N): ');
     readln(jogar);
     jogar := upcase(jogar);
     end;

end.
                                

Faça um programa que termine somente quando o usuario acerte o username e a password, sendo que o username deve ser "Zezim" e a password deve ser "Minha Senha"





program ExeploWhile1;
{ Faça um programa que termine somente quando o usuario acerte
o username e a password, sendo que o username deve ser "Zezim"
e a password deve ser "Minha Senha"}

var
  senha   :    string;
  usuario   :    string;

begin
   while((usuario <> 'ZEZIM') or (senha <> 'MinhaSenha'))do
   begin
     write('Digiete o Usuario: ');
     readln(usuario);
     write('Digite a senha : ');
     readln(senha);
   end;


end.                  

Fatorial de Um Numero





program fatorial1;
uses crt;
var
  i          : integer;
  s          : real;
  n          : integer;
begin
     s := 1;
  writeln('Digite o Valor: ');
  readln(n);

  for i:= 1 to n do
      s   :=   i / ((i -1) + I);
  writeln(' O valor de s ', n, ' eh ', s);



  readkey;
end.
                                                    

Soma Multiplos 5 e 7 Certo





program SomaMultiplos5e7Certo;
uses crt;
     var
       n   : integer;
       i   : integer;
       x   : integer;
       soma: integer;
begin
       i := 0;
        for i := 1 to 10000 do
        if (i mod 5 = 0) then
        begin
        n := i + n;
        end
         else
         if (i mod 7 = 0) then
         begin
         x := i + x;
         end;
         soma := (n + x);
           writeln( n:6,' ', 'Divisiveis por 5 ');
           writeln();
          writeln( x:6,' ', 'Divisiveis por 7 ');
          writeln();
         writeln(' Soma dos Multiplos de 5 e 7 entre 0 e 10.000 he : ', soma);

 readkey;
end.                           

String




program String;
uses crt;
   var
     nome        :      string[30];
     sobrenome   :      string[30];
     nomecompleto:      string[60];

begin
write('Digite o Nome :');
readln(nome);
write('Digite o Sobrenome :');
readln(sobrenome);
writeln();

                  nomecompleto := nome + ' ' + sobrenome;
             writeln (nomecompleto);
readkey;
end.
                              

String Como Utilizar Comandos




program string1;
uses crt;
 var
   valor         :      string;
   preco         :      real;
   deucerto      :      integer;
begin
 write('Digite o Valor: ');
 readln(valor);

 val(valor, preco, deucerto);

 writeln(valor);
 writeln();
 writeln(preco);
 writeln();
 writeln(deucerto);

 if (deucerto <> 0 ) then
    begin
      if (pos(',', valor) = deucerto) then
         begin
           delete(valor, deucerto, 1);
           insert('.',valor, deucerto);
           val(valor,preco,deucerto);
         end
    end;

 writeln(valor);
 writeln();
 writeln(preco);
 writeln();
 writeln(deucerto);

readkey;
end.
                         


Executa Tabuada do 1 ao 10. Função if and then, Função For.





//Executa Tabuada do 1 ao 10. Função if and then, Função For.

program tabuada;
 uses crt;
     Var
       x      :  integer;
       numero     :  integer;
begin
 writeln ('Digite o Numero Para Executar a Tabuada ');
 writeln();
 readln(numero);

     if (numero < 11) and (numero > 0) then
       begin
          writeln();
          for  x := 1  to 10 do
                 writeln(numero,' ',' x ',' ', x,' ', ' = ',' ',' ',(numero * x ));
                 writeln();
        end
        else if (numero < 0) then
             begin
               writeln ('Numero Negativo Menor que 0, Invalido ', numero);
               end

        else if (numero > 10) then
             begin
                writeln(' Numero Maior que 10 , Invalido ',numero);
                end;


readkey;
end.
                                                            

Tipos de Variaveis;





program tipos_variaveis;
uses crt;
    var
      alfanum           :       char;
      cad_caracters     :       string[30];
      numero            :       integer;
      num_real          :       real;
      verdade           :       boolean;

begin
    writeln('Digite um Caracter : ');
    readln(alfanum);
    writeln('Digite Nome e Endereço: ');
    readln(cad_caracters);
    writeln('Digite numero da residencia: ');
    readln(numero);
    writeln('CEP da Rua:   ');
    readln(num_real);
    verdade           :=      true;
      writeln(alfanum);
      writeln(cad_caracters);
      writeln(numero);
      writeln(num_real:4:2);
      writeln(verdade);
  readkey;
end.
                                        

Pascal - Lazarus