guilhoto Posted March 29, 2013 at 08:19 PM Report #500860 Posted March 29, 2013 at 08:19 PM (edited) #include <stdio.h> #include <stdlib.h> #include <string.h> int i=0, num_socio[1000],numero_socio=101, meses[1000], credito[1000], nModalidades[1000], conta=0, q=0; char lista_socios[1000][101]; char aux[101], modalidades[26][3]; char aux2[101], aux3[101]; int j=0,v=0,u, soma_creditos=0; int l,y; void registo(char* coise){ char aux[101]; if(q==2){ coise[0]=' '; num_socio[i]=numero_socio; meses[i]=0; credito[i]=0; nModalidades[i]=0; numero_socio++; i++; conta+=200; } else{ printf("Por favor introduza o registo no formato correcto: r 'Nome Proprio' 'Apelido'\n"); } return; } void inscricao(char* coise){ if((u-101)<0){ printf("Introduza um numero de socio valido!\n"); } for(j=0; j<26; j++){ if(aux[6]==modalidades[j][0]|| aux[7]==modalidades[j][0]){ break; } } modalidades[j][2]=modalidades[j][2]+'1'; conta+=10; nModalidades[u-101]++; credito[u-101]+=10; return; } void listas(char* aux){ if(aux[2]=='0'){ j=0; while(j<i){ printf("%d %s %d %d %d\n", num_socio[j], lista_socios[j], meses[j], credito[j], nModalidades[j]); j++; } } if(aux[2]=='1'){ j=0; while(j<i){ if(nModalidades[j]>0){ printf("%d %s %d %d %d\n", num_socio[j], lista_socios[j], meses[j], credito[j], nModalidades[j]); } j++; } } if(aux[2]=='2'){//falta ordenar da maior divida para a menor j=0; while(j<i){ if(credito[j]<0){ printf("%d %s %d %d %d\n", num_socio[j], lista_socios[j], meses[j], credito[j], nModalidades[j]); } j++; } } if(aux[2]=='3'){//falta ordenar da modalidade com + praticantes pra com - praticantes j=0; while(j<26){ if(modalidades[j][2]>0){ printf("%s %d\n", modalidades[j]); } j++; } } return; } void prox_mes(char* aux){ j=0; while(j<i){ if(nModalidades[j]>0){ credito[j]=credito[j]-(nModalidades[j]*10); } if(credito[j]<-100){ nModalidades[j]=0; } meses[j]++; j++; } printf("%d\n", conta); conta=0; return; } void desinscrever(char* aux){ if((u-101)<0){ printf("Introduza um numero de socio valido!\n"); } for(j=0; j<26; j++){ if(aux[6]==modalidades[j][0]|| aux[7]==modalidades[j][0]){ break; } } modalidades[j][2]=modalidades[j][2]-'1'; nModalidades[u-101]--; return; } main(){ while(j<26){ modalidades[j][0]=='A'+j; modalidades[j][1]==' '; modalidades[j][2]=='0'; } while(aux[0]!='x'){ scanf(" %[^\n]", &aux); char aux2[101]=""; v=0; j=0; q=0; while(j<=strlen(aux)&& q<2){ if(aux[j]=='0'||aux[j]=='1'||aux[j]=='2'||aux[j]=='3'|| aux[j]=='4'||aux[j]=='5'||aux[j]=='6'||aux[j]=='7'||aux[j]=='8'||aux[j]=='9'){ aux2[v]=aux[j]; v++; } if(aux[j]==' '){ q++; } j++; } v=0; while(j<=strlen(aux)){ if(aux[j]=='0'||aux[j]=='1'||aux[j]=='2'||aux[j]=='3'|| aux[j]=='4'||aux[j]=='5'||aux[j]=='6'||aux[j]=='7'||aux[j]=='8'||aux[j]=='9'){ aux3[v]=aux[j]; v++; } j++; } l=atoi(aux3); u=atoi(aux2); if(aux[0]=='r'){ registo(aux); strcpy(lista_socios[i-1], aux); } if(aux[0]=='i'){ inscricao(aux); } if(aux[0]=='l'){ listas(aux); } if(aux[0]=='+'){ prox_mes(aux); } if(aux[0]=='k'){ desinscrever(aux); } if(aux[0]=='p'){ credito[u-101]+=l; conta+=l; } soma_creditos=0; j=0; while(j<=i){ soma_creditos=soma_creditos + credito[j]; j++; } } printf("%d %d\n",i, soma_creditos); system("pause"); } este codigo compila sem erros nem warnings mas quando aparece a janela de comandos nao consigo escrever nada nela...alguem sabe porque? Edited March 29, 2013 at 08:32 PM by pmg Falta LP no GeSHi
AJBM Posted March 29, 2013 at 08:29 PM Report #500862 Posted March 29, 2013 at 08:29 PM Boas! Ve se consegues por o código mais bem identado. Eu não vejo main nenhum, onde tens o teu main?
thoga31 Posted March 29, 2013 at 08:36 PM Report #500863 Posted March 29, 2013 at 08:36 PM (edited) Boas! Ve se consegues por o código mais bem identado. Eu não vejo main nenhum, onde tens o teu main? Ele não declarou o main com um tipo de dados. Tens de procurar melhor por ele, ou fazer um Find com o teu browser caso não o desencantes mesmo: main(){ while(j<26){ modalidades[j][0]=='A'+j; modalidades[j][1]==' '; modalidades[j][2]=='0'; // etc... @guilhoto, experimenta fazer a inicialização de todas as variáveis (fazer uma limpeza). A primeira cosia que tens são Whiles sem qualquer inicialização prévia. Edited March 29, 2013 at 08:37 PM by thoga31 Knowledge is free!
guilhoto Posted March 29, 2013 at 08:45 PM Author Report #500864 Posted March 29, 2013 at 08:45 PM o meu main e a ultima funçao de todas... while(j<26){ modalidades[j][0]=='A'+j; modalidades[j][1]==' '; modalidades[j][2]=='0'; } e aqui que ele bloqueia. tentei meter no fim e um printf depois disto para imprimir a string modalidades[0] e nao imprimiu nada...alias carreguei no x para sair do programa onde iria fazer este ciclo e o print e nao fez nada...penso que o problema esta neste ciclo mas porque?
guilhoto Posted March 29, 2013 at 08:57 PM Author Report #500868 Posted March 29, 2013 at 08:57 PM meu deus nem acredito que cometi este erro xD...esqueci-me de incrementar o j...isto de muitas horas seguidas as vezes da nisto xD. peço desculpa por ter perdido o vosso tempo...
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