Jump to content

Recommended Posts

Posted

eh fdx.... esqueci-me completamente.... :|

Aqui tens em c++, percebe-se bem, penso eu:

#include <iostream>
using namespace std;

int main () {
int escolha;
do {
cout << endl << endl << "****************SUPER-HELLO WORLD PROGRAM*******************";
cout << endl << "1 - Hello world normal" << endl;
cout << "2 - Enhanced hello world" << endl;
cout << "3 - Hyper Hello world" << endl;
cout << "4 - End" << endl;
cout << endl << "Insira a escolha: "; cin >> escolha;
switch (escolha) {
	case 1 : cout << endl << endl << "Hello World!"; break;
	case 2: cout << endl << endl << "Wake up you bastards!"; break;
	case 3: cout << endl << endl << "Fucking loosers, say a fucking hello to fucking me!"; break;
	case 4: continue;
	default : cout << endl << endl << "Insert on me a fuckying valid option you fag"; break;
} }while (escolha != 4);
return 0; 
}
Posted

em pascal é mais ou menos isto..

   

while opcao<>5 do
           begin
                write('1- potencia.');
                writeln('2-ler fixeiro.');
                writeln('3-escrever em fixeiro.');
                writeln('4-copiar fixeiro.');
                readln(opcao);
                case opcao of
                         1:potencia;
                          2:lerfix('0818.txt');
                          3:escrevefix('0818.txt');
                     end;
           end;[/code

isso é so um exemplo que eu copiei aqui de um programa qualquer que tenho aqui..
cumps.
Posted

Bem axo k nao me fiz entender.

O meu problem vem daki:

Tenhu um menu principal

writeln('1- ver documento');
writeln('2-ecrever etc....');
writeln('3-sair');
readln(a);
if a=1 then
  begin
          verdocumento;
end;
if a=2 then
  begin
          escrever;
  end;
if a=3 then
  begin
         exit;
  end; 

etc 
etc
etc 

Ao entrar na opçao 1 o meu programa deixa-me ver reralmente o documento mas o

k eu keria era ter tipo outro menu um que desse para voltar para o menu principal e outra sair,

Para Sair é fácil agora não estou a conseguir voltar ao menu principal, pois o menu

principal não é  PROCEDIMENTO (PROCEDURE).

Através do While até faz sentido mas o problema é que quando entro na opçao 1......

Posted

Entao podes fazer, em todos os menus, um Sair, po exemplo:

program test;
uses crt;
var
a, b, n1, n2, n3:integer
writeln('1 - Soma');
writeln('2 - Divisão');
writeln('3 - Sair');
readln(a);
case a of
1: begin
writeln('1º Valor');
readln(n1);
writeln('2º Valor');
readln(n2);
n3:=n1+n2;
writeln('O Resultado é ',n3);
end;
writeln('3 - Sair');
case b of
3 : begin
exit;
end;
case a of
2 : begin
writeln('1º Valor');
readln(n1);
writeln('2º Valor');
readln(n2);
n3:=n1 Div n2;
writeln('O Resultado é ',n3);
end;
writeln('3 - Sair');
case b of
3 : begin
exit;
end;
case a of
3 : begin
exit;
end;
end.
Posted

Então e porque não transformas o menu num procedure?

Penso que se tornava muito mais simples.

1:
begin
      ....
      write('99 - menu');
      read(var);
      if var = 99
           menu;
end;

Isto é uma maneira de ver...

Cumps,

  • 1 month later...
Posted

Podes usar uma label que é bastante simples...

program qlqcoisa;

uses crt;

label inicio;

var ....

begin

inicio:

writeln('MENU PRINCIPAL....');

readln(a);

case a of

1:  begin

....

goto to inicio;

end;

end.

Espero ter ajudado.. 

Posted

usas um ciclo do.. while

Exactamente, podes usar um ciclo While...Do ou então Repeat...Until.

::Exemplo do programa principal, usando 3 subprogramas:

While...Do

BEGIN
     resp:='s';
     while (resp='s') do
         clrscr;        
         writeln('1 - ver resultados');
         writeln('2 - inserir dados'); 
         writeln('3 - sair');
         case (opcao) of        
            1:ver_resultados;
            2:inserir_dados; 
            3:sair;
         else writeln('Opcao invalida');
         end;
 writeln('Quer voltar ao menu inicial?(s/n)');
 readln(resp);        
     end;
END.

Repeat...Until

BEGIN
     repeat 
          clrscr;        
          writeln('1 - ver resultados');
          writeln('2 - inserir dados'); 
          writeln('3 - sair');
          case (opcao) of        
             1:ver_resultados;
             2:inserir_dados; 
             3:sair;
          else writeln('Opcao invalida');
          end;
  writeln('Quer voltar ao menu inicial?(s/n)');
  readln(resp);        
     until (resp='n');
END.

Se não é isto não tou a ver kal é o problema...😛

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.