pestynha Posted June 11, 2012 at 03:56 PM Report Share #462005 Posted June 11, 2012 at 03:56 PM (edited) fiz este pedaço de codigo anexo em baixo . o que quero que ele faça a seguir é quando entrar no menu 1 apresente regras e possibilite voltar ao menu anterior . outra coisa o programa ta a sair quando se da 2 enters qual a soluçao ? obrigado #include <conio.h> #include <stdio.h> #include <stdlib.h> main() { } Edited June 14, 2012 at 07:39 AM by pestynha Adicionei GeSHi e indentacao Link to comment Share on other sites More sharing options...
pikax Posted June 11, 2012 at 04:19 PM Report Share #462012 Posted June 11, 2012 at 04:19 PM (edited) Torna os teus tópicos mais atractivos e legíveis usando a tag CODE para colorir o código! Edited June 11, 2012 at 04:19 PM by pikax Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast." Link to comment Share on other sites More sharing options...
pmg Posted June 11, 2012 at 10:00 PM Report Share #462077 Posted June 11, 2012 at 10:00 PM (edited) Nao te falta um while algures no codigo? Sem um ciclo, o programa nao repete nada. Edited June 11, 2012 at 10:01 PM by pmg What have you tried? Não respondo a dúvidas por PM A minha bola de cristal está para compor; deve ficar pronta para a semana. Torna os teus tópicos mais atractivos e legíveis usando a tag CODE para colorir o código! Link to comment Share on other sites More sharing options...
pestynha Posted June 12, 2012 at 08:14 AM Author Report Share #462102 Posted June 12, 2012 at 08:14 AM ate falta 🙂 } while (opcao!=0); printf("\n\n O Programa foi fechado"); getch(); } o meu problema agora é como abro um sub menu? Obrigado Link to comment Share on other sites More sharing options...
pikax Posted June 12, 2012 at 08:46 AM Report Share #462106 Posted June 12, 2012 at 08:46 AM penso que nao seja esse while Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast." Link to comment Share on other sites More sharing options...
mundo Posted June 12, 2012 at 09:05 AM Report Share #462108 Posted June 12, 2012 at 09:05 AM (edited) Porque nao algo como: #define MENU "[1]regras\n [2]jogo\n[3]Sair\n" #define SUBMENU "[1] voltar ao menu anterior\n[2]Sair\n" void menuPrincipal(){ char opcao; do{ printf(MENU); scanf(" %c", &opcao); switch(opcao){ case 1: submenu(); break; case 2: initjogo(); break; case 3: exit(0); break; default: printf("opcao invalida"); } while(opcao != 3); } void submenu(){ char opcao; do{ printf(SUBMENU); scanf(" %c", &opcao); switch(opcao){ case 1: menu_principal(); break; case 2: exit(1); break; default: printf("opcao invalida"); } }while(opcao != 2); } int main(char argc, **char argv){ menu_principal(); } Edited June 12, 2012 at 09:07 AM by mundo Link to comment Share on other sites More sharing options...
pestynha Posted June 12, 2012 at 11:14 AM Author Report Share #462139 Posted June 12, 2012 at 11:14 AM (edited) io pessoal ja fiz o sub menus mas tou com um problema nao volta ao principal vou postar o ficheiro com o codigo peço desculpa nao consegui meter as corzinhas #include <conio.h> #include <stdio.h> #include <stdlib.h> void MenuPrincipal(void); int submenu(void); void galo (void); int main (void) }while(resp=='s' || resp=='S'); } } Edited June 14, 2012 at 07:40 AM by pestynha Link to comment Share on other sites More sharing options...
pikax Posted June 12, 2012 at 11:20 AM Report Share #462143 Posted June 12, 2012 at 11:20 AM peço desculpa nao consegui meter as corzinhas substitui o [ CODE] por [ CODE=C] (mas sem o espaco) 1 Report Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast." Link to comment Share on other sites More sharing options...
bsccara Posted June 12, 2012 at 11:57 AM Report Share #462157 Posted June 12, 2012 at 11:57 AM Não chames a função MenuPrincipal na submenu. Em vez de : ... case 2: MenuPrincipal(); ... } while(opcao1!=0); getch(); faz: ... case 2: break; ... } while (opcao1 != 2); Limpa também os teus 'case's; tens chavetas a mais dentro e linhas que nunca são executadas (procura). Link to comment Share on other sites More sharing options...
pestynha Posted June 12, 2012 at 03:10 PM Author Report Share #462244 Posted June 12, 2012 at 03:10 PM (edited) boas pareçe que ta terminado so tenho duas duvidas que esta ai colocadas #include <conio.h> system("cls"); //Limpa a tela para recomeçar o jogo. }while(resp=='s' || resp=='S'); } Edited June 14, 2012 at 07:40 AM by pestynha Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted June 12, 2012 at 03:18 PM Report Share #462251 Posted June 12, 2012 at 03:18 PM no que toca à primeira questão : basta pores uma entrada no switch switch (...) { case 0: // desta forma não entra no default e falha no while, não é necessário mais nada break; } a segunda questão não percebi .. que texto ?? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
pestynha Posted June 12, 2012 at 05:13 PM Author Report Share #462319 Posted June 12, 2012 at 05:13 PM boas obrigado pela ajuda a segunda é o testo todo que ta nas regras? é possivel colocar tudo so com um printf ? como o formato? Link to comment Share on other sites More sharing options...
carlospimenta Posted June 12, 2012 at 08:38 PM Report Share #462350 Posted June 12, 2012 at 08:38 PM ola sou novo aqui queria saber como fazer um stwich como este? obrigado....percebo alguma coisa de programação http://img831.imageshack.us/img831/9612/capturarri.jpg Link to comment Share on other sites More sharing options...
pikax Posted June 12, 2012 at 08:42 PM Report Share #462352 Posted June 12, 2012 at 08:42 PM ola sou novo aqui queria saber como fazer um stwich como este? obrigado....percebo alguma coisa de programação http://img831.images.../capturarri.jpg como assim??? Nao sabes fazer um switch e queres fazer algo assim em C? :O Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast." Link to comment Share on other sites More sharing options...
carlospimenta Posted June 12, 2012 at 08:57 PM Report Share #462354 Posted June 12, 2012 at 08:57 PM (edited) como assim??? Nao sabes fazer um switch e queres fazer algo assim em C? :O como assim??? Nao sabes fazer um switch e queres fazer algo assim em C? :O sim podias-me ajudar...... please......se kiseres tenho convites scenetush pra oferecer...entre outras coisas Edited June 12, 2012 at 09:03 PM by carlospimenta Link to comment Share on other sites More sharing options...
pikax Posted June 12, 2012 at 09:04 PM Report Share #462358 Posted June 12, 2012 at 09:04 PM LOL?? ve se este link te ajuda http://www.portugal-a-programar.pt/guidelines/ Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast." Link to comment Share on other sites More sharing options...
carlospimenta Posted June 12, 2012 at 09:21 PM Report Share #462361 Posted June 12, 2012 at 09:21 PM ok eu percebi::::: a publicidade mas ajuda-me lá ...please é a ultima ccoisa ke te peço Link to comment Share on other sites More sharing options...
KTachyon Posted June 12, 2012 at 09:22 PM Report Share #462362 Posted June 12, 2012 at 09:22 PM Sabes fazer condições (if, else if, else)? “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare Link to comment Share on other sites More sharing options...
carlospimenta Posted June 12, 2012 at 09:23 PM Report Share #462363 Posted June 12, 2012 at 09:23 PM #include <stdio.h> int main () { int num; printf ("Digite um numero: "); scanf ("%d",&num); if (num>10) printf ("\n\nO numero e maior que 10"); if (num==10) { printf ("\n\nVoce acertou!\n"); printf ("O numero e igual a 10."); } if (num<10) printf ("\n\nO numero e menor que 10"); return(0); como isto? Link to comment Share on other sites More sharing options...
KTachyon Posted June 12, 2012 at 09:26 PM Report Share #462364 Posted June 12, 2012 at 09:26 PM Basicamente, um switch, é como se fosse um conjunto de condições. Mas em vez de teres: if (a == 1) { // faz 1 } else if (a == 2) { // faz 2 } else if (a == 3) { // faz 3 } else { // faz outro } Fazes: switch (a) { case 1: // faz 1 break; case 2: // faz 1 break; case 3: // faz 1 break; default: // faz outro Lembra-te de colocar o break, caso contrário, todos os casos que estão a baixo são executados. “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now