Пример #1
0
main()
{
  int choice, n;
  char xaugoc[40], xau[40];

  game person[T];

  do{
    choice=menu();    
    switch(choice)
      {
      case 1:
    	printf("Nhap xau: ");
    	nhapxau(xaugoc);
    	printf("Nhap so nguoi choi: ");
    	n = soluong(1, 4);
    	danhsach(person, n);
    	printlist(person, n);
      break;
      case 2:
	    play(person, n, xaugoc);
      break;
      case 3:
    	sapxep(person, n);
    	printlist1(person, n);
    	break;
      }
  } while(choice != 4);
}
Пример #2
0
int main(int argc,char* argv[])
{
    FILE *fIN=NULL;
    FILE *fOUT=NULL;
    if(processArgs(argc,argv,&fIN,&fOUT))
    {
        char* buff=malloc(256);char name[10],asdf[10];
        int node,from,to,offset;
        ListT* listn=(ListT*)malloc(sizeof(ListT));
        ListT* liste=(ListT*)malloc(sizeof(ListT));
        listn->first=NULL;
        liste->first=NULL;
        listn->lenght=0;
        liste->lenght=0;
        fgets(buff,256,fIN);
        sscanf(buff,"%s %s",name,asdf);
        buff+=strlen(name)+strlen(asdf)+2;
        Nodedata* toins=(Nodedata*)malloc(sizeof(Nodedata));
        while(sscanf(buff,"%d%n",&node,&offset))
        {
            buff+=offset;
            if(offset<strlen(buff))
            {
                toins=createdata1(node);
                insert(listn,toins);
            }
        }
        printlist1(listn);



        int offset1;
        fgets(buff,256,fIN);
        sscanf(buff,"%s %s",name,asdf);
        buff+=strlen(name)+strlen(asdf)+2;
        Edgedata* toins1=(Edgedata*)malloc(sizeof(Edgedata));
        while(sscanf(buff,"(%d%n %d%n)",&from,&offset,&to,&offset1))
        {
            buff+=offset+offset1;
            if(offset+offset1<strlen(buff))
            {
                toins1=createdata2(from,to);
                insert(liste,toins1);
            }
        }
        printlist2(liste);


        ListT* listnew=(ListT*)malloc(sizeof(ListT));
        listnew->first=NULL;
        listnew->lenght=0;
        fgets(buff,256,fIN);
        sscanf(buff,"%s %s",name,asdf);
        buff+=strlen(name)+strlen(asdf)+2;
        while(sscanf(buff,"%d%n",&node,&offset))
        {
            buff+=offset;
            if(offset<strlen(buff))
            {
                toins=createdata1(node);
                insert(listnew,toins);
            }
        }
        printlist1(listnew);

        NodeT* pWalker=liste->first;

        ListT* listnewedge=(ListT*)malloc(sizeof(ListT));
        listnewedge->first=NULL;
        listnewedge->lenght=0;
        int newfrom,newto;
        newfrom=((Edgedata*)(pWalker->data))->from;
        newto=((Edgedata*)(pWalker->data))->to;
        while(pWalker!=NULL)
        {

            newfrom=((Edgedata*)(pWalker->data))->from;
            newto=((Edgedata*)(pWalker->data))->to;
            if(find(listnew,newto)&&find(listnew,newfrom))
            {
                toins1=createdata2(newfrom,newto);
                insert(listnewedge,toins1);
            }
            pWalker=pWalker->next;
        }
        printlist2(listnewedge);

    }
}