С++ , как разобраться
Модераторы: Хыиуду, MOTOCoder, Medved, dr.Jekill
Разработка программ!
На языках: Pascal, Delphi, C/C++ Builder/Visual Studio C++, разработка программ для КПК
Выполнение любых работ для студентов!
ICQ: 371670735
На языках: Pascal, Delphi, C/C++ Builder/Visual Studio C++, разработка программ для КПК
Выполнение любых работ для студентов!
ICQ: 371670735
-
- Сообщения: 8
- Зарегистрирован: 24 ноя 2008, 21:54
problema kak sozdat ''case 5 s recherche_id(samourai*,int); '' i vkluchit ego v menu
Код: Выделить всё
#include<alloc.h>
#include<stdio.h>
#include<malloc.h>
#include<conio.h>
#define taille 50
typedef struct samourai {
int id;
char nom[taille];
char prenom[50];
int age;
char numero [10];
struct samourai *prev ;
struct samourai *next;
}
SAMOURAI ;
SAMOURAI* init(SAMOURAI*);
void affiche (SAMOURAI*);
void recherche_nom(SAMOURAI*,char);
//void recherche_id(samourai*,int);
SAMOURAI* erase (SAMOURAI*,int);
SAMOURAI* init (SAMOURAI *prem)
{
SAMOURAI *f, *temp;
//f== malloc(sizeof(SAMOURAI));
f=(SAMOURAI*)malloc(sizeof(SAMOURAI));
if (f!=NULL) {
printf ("-> sozdanie nomera samourai \n");
scanf("%i",&(f->id));
printf("-> vashe imia ?\n");
scanf("%s",f->nom);
printf("-> vash vozrast \n");
scanf("%i",&(f->age));
printf("-> vvedite nomer telefona \n");
scanf("%s",f->numero);
if (prem!=NULL)
{
temp=prem;
while (temp->next!=NULL)
{
temp=temp->next;
}
temp->next=f;
f->prev=temp;
f->next=NULL;
}
else {
f->prev=NULL;
f->next=NULL;
}
return f;
}
else return NULL;
}
// ---------------->>>>> recherche_id(samourai*,int);
//{
//samorai temp*;
//temp=prem;
//while (temp!= NULL) { printf("%i",prem);
void affiche (SAMOURAI* f)
{
printf("%i %s %i %s \n",f->id,f->nom,f->age,f->numero);
}
void recherche_nom (samourai *prem, char n)
{
SAMOURAI *temp;
temp=prem;
while (temp!=NULL)
{
if (temp->nom[0]==n){
affiche(temp);
}
temp=temp->next;
}
}
SAMOURAI* erase (SAMOURAI *prem, int id)
{
SAMOURAI *temp,*newfirst;
temp=prem;
int found=0;
while (temp!=NULL && found==0)
{
if ( temp->id==id) found =1;
else temp=temp->next;
}
if (temp!=NULL) {
if (temp==prem) {
prem=prem->next;
if (prem!=NULL) prem->prev=NULL;
}
else {
(temp->prev ) -> next=temp ->next;
(temp->next)-> prev=temp->prev;
}
//free(temp);
}
return prem;
}
int main()
{
SAMOURAI *prem,*temp;
prem=NULL;
temp=NULL;
int choix=0,supp=-1,k;
char c;
do {
printf("menu\n");
printf("0 vihod .\n");
printf("1 dobavit familiy .\n");
printf("2 udalit' po nomeru .\n");
printf("3 naity familiy po bukve.\n");
printf("4 pokazat vse soderjimoe.\n");
printf("5 udalenie nujniy nomer samouraya\n");
scanf("%d",&choix);
switch(choix) {
case 1: if(prem==NULL) prem=init(NULL);
else init(prem);
break;
case 2: printf("nomer telefona? \n");
scanf("%d",&supp);
prem=erase (prem,supp);
if (k==0) printf("net takoi familii .\n");
else printf(" oshibka .\n");
break;
case 3: printf(" vasha bukva.\n");
getchar();
scanf("%c",&c);
recherche_nom(prem,c);
break;
case 4 : temp=temp ;
while (temp!=NULL) {
affiche(temp);
temp=temp->next;
}
break;
//--------------->>>> case 5 :
default: break;
}
} while (choix!=0);
}