Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * File: main.c
- * Author: leandro
- *
- * Created on 16 de Setembro de 2011, 20:17
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define TRUE 1
- struct tagNOME {
- char Primeiro[16];
- char Ultimo[16];
- };
- struct tagDATAS {
- int Dia, Mes, Ano;
- };
- struct tagMORADAS {
- char Rua[20];
- int Andar;
- char Lado;
- };
- struct tagAlunos {
- struct tagNOME nome;
- struct tagDATAS Data_nasc;
- int Numero;
- int Num_Tele;
- struct tagMORADAS Morada;
- };
- void Mostrar(struct tagAlunos Alunos);
- void MenuP(void);
- void OpenMenu(void) { system("clear"); MenuP(); }
- void MostrarAluno(int Num_Alunos, struct tagAlunos Alunos[]);
- void Procurar(struct tagAlunos Aluno);
- void AddAluno(struct tagAlunos Aluno) {
- system("clear");
- printf("\n\t\tAdicionar Aluno\n\n");
- printf("Primeiro Nome: ");
- scanf("%s", Aluno.nome.Primeiro);
- printf("\nSegundo Nome: ");
- scanf("%s", Aluno.nome.Ultimo);
- printf("\nData de Nascimento <dd/mm/aa>: ");
- scanf("%d/%d/%d", &Aluno.Data_nasc.Dia, &Aluno.Data_nasc.Mes, &Aluno.Data_nasc.Ano);
- printf("\nMorada <Rua, Andar-Lado>: ");
- //scanf("%s", Aluno.Morada.Rua);
- scanf("%d-%c", &Aluno.Morada.Andar, &Aluno.Morada.Lado);
- printf("\nTelemovel: ");
- scanf("%d", &Aluno.Num_Tele);
- system("clear");
- }
- int main(int argc, char** argv) {
- int Num_Aluno;
- char Ask;
- struct tagAlunos Alunos[1000];
- Num_Aluno = 0;
- Ask = NULL;
- while(TRUE) {
- OpenMenu();
- printf("\nOpcao: ");
- fflush(stdin);
- Ask = getchar();
- OpenMenu();
- if( Ask == 'a' || Ask == 'b' || Ask =='c' ) {
- if( Ask == 'a' ) {
- AddAluno(Alunos[Num_Aluno]);
- Alunos[Num_Aluno].Numero = Num_Aluno;
- Num_Aluno++;
- }
- else if( Ask == 'c' ) {
- MostrarAluno(Num_Aluno, Alunos);
- }
- }
- }
- return (EXIT_SUCCESS);
- }
- void Mostrar(struct tagAlunos Alunos) {
- printf("\nNome\n");
- printf(" primeiro: %s\n", Alunos.nome.Primeiro);
- printf(" segundo: %s\n", Alunos.nome.Ultimo);
- printf("\nData de Nascimento <DD/MM/AA>: ");
- printf("%d/%d/%d \n", Alunos.Data_nasc.Dia, Alunos.Data_nasc.Mes, Alunos.Data_nasc.Ano);
- printf("\nNumero escolar: %d\n", Alunos.Numero);
- printf("Telemovel: %d\n\n", Alunos.Num_Tele);
- }
- void MenuP(void) {
- printf("\n\t\tMenu Principal\n\n");
- printf("\ta - Adicionar Alunos\n");
- printf("\tb - Remover Alunos\n");
- printf("\tc - Ver Alunos\n");
- }
- void MostrarAluno(int Num_Alunos, struct tagAlunos Alunos[]) {
- int aux, find;
- aux = find = 0;
- system("clear");
- printf("\t\tMostrar Alunos\n\n");
- while(Num_Alunos >= 0){
- if(aux % 2 == 0)
- printf("\n");
- printf("\tAluno: %d", Alunos[Num_Alunos].Numero);
- Num_Alunos--;
- aux++;
- }
- printf("\n\nDigite o numero do aluno que quer procurar: ");
- scanf("%d", &find);
- if(find < 0 || find > Num_Alunos)
- printf("\n\nNão encontrado!\n\n");
- else
- Procurar(Alunos[find]);
- }
- void Procurar(struct tagAlunos Aluno) {
- system("clear");
- printf("\tNome\n");
- printf("Primeiro: %s \n", Aluno.nome.Primeiro);
- printf("Ultimo: %s \n", Aluno.nome.Ultimo);
- printf("Data de Nascimento <dd/mm/aa>: %d/%d/%d\n", Aluno.Data_nasc.Dia, Aluno.Data_nasc.Mes, Aluno.Data_nasc.Ano);
- printf("Telemovel: %d\n\n\n", Aluno.Num_Tele);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement