CIAO RAGAZZI,HO BISOGNO DI UN GRANDE AIUTO..HO DA
FARE UNA SIMPATICA RUBRICA CON LE STRUTTURE,CON TANTO DI INSERIMENTO,MODIFICA,RICERCA(DICOTOMICA)E CANCELLAZIONE...INTANTO VI POSTO IL CODICE CHE HO FATTO FIN ORA,PERCHE MI SONO BLOCCATO QUI...SE MI DATE 1 MANO VI RINGRAZIO.
#include <iostream.h>
#include <window.h>
#include <stdio.h>
#include <string.h>
struct Persona
{
char Nome[15],Cognome[20],Numero[50];
};
Persona vet[50];
void main (void)
{
//variabili main
bool flag;
char risp;
int i=0,j=0,k=0,temp;
//struttura con informazioni persona
struct temp
{
char Nome[15],Cognome[20];
};
Persona Vet[1];
do
{
flag=true;
cout <<"Rubrica "<<endl;
cout <<endl;
cout <<endl;
cout <<"quale operazione vuoi svolgere "<<endl;
cout <<" 1)inserisci nuovo"<<endl;
cout <<" 2)elimina contatto"<<endl;
cout <<" 3)ricerca"<<endl;
cout <<" 4)stampa tutto"<<endl;
cout <<" 5)chiudi"<<endl;
cout <<"inserire il numero corrispondente alla scelta\n\n"<<endl;
do
{
cin>>risp;
}
while(risp!='1'&&risp!='2'&&risp!='3'&&risp!='4'&&risp!='5');
switch(risp)
{
case '1':
{
cout<<"inserire il nome"<<endl;
gets(Vet[0].Nome);
cout<<"inserire il cognome"<<endl;
if (i>0)
{
do
{
gets(Vet[0].Cognome);
for(j=i;j>=0&&flag ==true;j--)
{
if (strcmp (vet[j].Cognome,Vet[0].C)
cout<<"inserire il numero di telefono"<<endl;
gets(vet.Numero);
}
for(j=i;j>=0&&flag ==true;j--)
{
if ( strcmp (vet[j].Cognome,Vet[0].Cognome)>0)
{
j=i;
flag=false;
}
}
i++;
}
break;
case '2':
flag=true;
{
cout <<"inserisci il cognome dell\'elemento da eliminare "<<endl;
gets(Vet[0].Cognome);
for(j=i;j>=0&&flag==true;j--)
{
if (strcmp (vet[j].Cognome,Vet[0].Cognome)==0)
{
temp=j;
flag=false;
}
}
for(j=temp;j<=i;j++)
{
vet[j]=vet[j+1];
}
i--;
}
break;
case '3':
{
}
break;
case '4':
{
system("CLS");
for(k=0;k<i;k++)
{
cout <<" "<<(k+1)<<") ";
cout <<vet[k].Nome<<endl;
cout <<" "<<vet[k].Cognome<<endl;
cout <<" "<<vet[k].Numero<<endl;
cout <<endl;
}
system ("pause");
}
break;
case '5':
{
break;
}
break;
}
system ("cls");
}while (risp!='5');
}
|