コード例 #1
0
ファイル: main.c プロジェクト: Alecs94/DSA-lab
NodeL* getListFromTree(NodeT* root)
{
    if(root!=NULL)
    {
        addlast(root->data);
        getListFromTree(root->left);
        getListFromTree(root->right);
    }
    else
        addlast('*');
    return head;
}
コード例 #2
0
ファイル: main.c プロジェクト: KovaxG/aut-eng-2014
int main()
{
    int n;
    init();
    addfirst(12);
    addlast(9);
    n=count();

    afisare();
node_t *b=keyfind(4);
if(b!=NULL)

{
    printf("%d",b->k);
}
else{printf("Valoarea nu exista");}

    removekey(2);
    afisare();
    printf("%d",count());




    return 0;
}
コード例 #3
0
ファイル: fakdata.cpp プロジェクト: Premislaus/beos-fakBEtur
void pozfaklist::fetch(int fakturaid) {
///printf("fetchpozfak id=%i\n", fakturaid);
	pozfakdata *data;
	int i, j;
	int nRows, nCols;
	char **result;
	BString sql, cbrutto;	

	// clear current list!
	clear();

	sql = "SELECT ";
	sql += "id, lp, ilosc";
	sql += ", nazwa, pkwiu, jm, vatid, netto, rabat";
	sql += " FROM pozycjafakt WHERE fakturaid = ";
	sql << fakturaid;
	sql += " ORDER BY lp";
//printf("sql:%s\n",sql.String());
	sqlite_get_table(dbData, sql.String(), &result, &nRows, &nCols, &dbErrMsg);
//printf ("got:%ix%i, %s\n", nRows, nCols, dbErrMsg);
	if (nRows < 1)
		return;
	// readout data
	i = nCols;
	j = 1;
	while (j <= nRows) {
		data = new pozfakdata();
		i++;							// id, unused
		data->data[0] = result[i++];	// lp, unused
		data->data[3] = result[i++];	// ilosc
		data->data[1] = result[i++];	// nazwa
		data->data[2] = result[i++];	// pkwiu
		data->data[4] = result[i++];	// jm
		data->vatid = toint(result[i++]); //vatid
		data->data[11] = result[i++];	// c.netto
		data->data[5] = result[i++];	// rabat
		addlast(data);
		// 6, 7, 8, 9, 10 - cjednost, w.netto, vat, wvat, wbrutto
		int nCols;
		char **result = calcBrutto(data->data[11].String(), data->data[5].String(), data->data[3].String(), data->vatid, &nCols);
		if (nCols<1) {
			data->data[6] = data->data[7] = data->data[9] = data->data[10] = "";
		} else {
			data->data[6] = result[nCols+0];
			data->data[7] = result[nCols+3];
			data->data[9] = result[nCols+4];
			data->data[10] = result[nCols+5];
		}
		calcBruttoFin(result);
		// vat = stawka
		sql = "SELECT nazwa FROM stawka_vat WHERE id = "; sql << data->vatid;
		data->data[8] = execSQL(sql.String());
		j++;							// next row
	}
	sqlite_free_table(result);
	setlp();							// reset lp
}
コード例 #4
0
ファイル: main.c プロジェクト: vikks143/atclib
int main()
{
	int  ch, val,pos;
	printf("\nEnter to the world of Link List:");
	getch();
	while(1)
	{
		system("cls");
		printf("\n0 >Eixt\n1 >AddFirst \n2 >Insert \n3 >AddLast \n4 >DeleteFirst \n5 >DeleteNode \n6 >DeleteLast\n7 >Display \n9 >Print Reversly \n10 >Freelist \n");
		scanf("%d", &ch);
		switch(ch)
		{
			case 0:
					exit(0);
			case 1:
					printf("\nEnter the number : ");
					scanf("%d", &val);
					addfirst(val);
					break;
			case 2:
					printf("\nEnter the number and position :");
					scanf("%d%d", &val,&pos);
					insert(val,pos);
					break;
			case 3:
					printf("\nEnter the number : ");
					scanf("%d", &val);
					addlast(val);
					break;
			case 4:
					delfirst();
					break;
			case 5:
					printf("\nEnter the position :");
					scanf("%d",&pos);
					deletenode(pos);
					break;
			case 6:
					dellast();
					break;
			case 7:
					display();
					break;
			case 9:
					printrev(head);
					break;
			case 10:
					freelist();
					break;
			default :
					printf("\nEnter the correct choice ");
		}
		getch();
	}
	return 0;
}
コード例 #5
0
int main()
{
	int data,p;
	char another ='y';
	dnode*dhead=NULL;
	dnode * temp=NULL;
	//add first
	while ( another =='y')
	{
		scanf("%d",&data,printf("enter data"));fflush(stdin);
		dhead = add(dhead,data);
		scanf("%c",&another,printf("want to add another "));fflush(stdin);
	}
	temp=dhead;
	while(temp!=NULL)
	{
		printf("%d",temp->data);
		temp=temp->link;
	}
	another='y';
	//add last
	while ( another =='y')
	{
		scanf("%d",&data,printf("enter data"));fflush(stdin);
		dhead = addlast(dhead,data);
		scanf("%c",&another,printf("want to add another "));fflush(stdin);
	}
	temp=dhead;
	while(temp!=NULL)
	{
		printf("%d",temp->data);
		temp=temp->link;
	} 
	
	
	// add at p position
	another = 'y';
	while ( another =='y')
	{
		scanf("%d",&data,printf("enter data :"));fflush(stdin);
		scanf("%d",&p,printf("enter position :"));fflush(stdin);
		dhead = add_at_p(dhead,data,p);
		temp=dhead;
		while(temp!=NULL)
		{
			printf("%d",temp->data);
			temp=temp->link;
		} 
		scanf("%c",&another,printf("\nwant to add another "));fflush(stdin);
	}
	
	return 0;
}
コード例 #6
0
ファイル: main.c プロジェクト: Alecs94/DSA-lab
int main()
{
    FILE *f;
    f=fopen("input.dat","r");
    if(f==NULL)
    {
        perror("cannot create file!");
        return -1;
    }
    char s[20];
    int code;
    FILE *ff;
    ff=fopen("output.dat","w");
    if(ff==NULL)
    {
        perror("cannot create file!");
        return -1;
    }
    while(fscanf(f,"%s ",s)==1)
    {
        if((strcmp(s,"AF")==0)||(strcmp(s,"AL")==0)||(strcmp(s,"DE")==0)||(strcmp(s,"PRINTF_F")==0)||(strcmp(s,"PRINT_L")==0))
           {

            fscanf(f,"%d ",&code);
            printf("%s %d\n",s,code);
           }
        else
            printf("%s\n",s);
            if(strcmp(s,"AL")==0)
            addlast(code);
            if(strcmp(s,"AF")==0)
            addfirst(code);
            if(strcmp(s,"DE")==0)
            delete_a_node(code);
            if(strcmp(s,"PRINT_F")==0)
            print_the_first_nodes(ff,code);
            if(strcmp(s,"PRINT_L")==0)
            print_the_last_nodes(ff,code);
            if(strcmp(s,"DF")==0)
            deletefirst();
            if(strcmp(s,"DL")==0)
            deletelast();
            if(strcmp(s,"DOOM_THE_LIST")==0)
            delete_the_list();
            if(strcmp(s,"PRINT_ALL")==0)
            printlist(ff);

    }
    fclose(f);
    return 0;
}
コード例 #7
0
ファイル: main.c プロジェクト: ChevalCorp/RayTracer
void		init_conf(t_rtv1 *rt, int ac, char **av)
{
  int		fd;
  char		*newline;

  if (ac < 1 && ac > 2)
    exit(1);
  if ((fd = open(av[1], O_RDONLY)) == -1)
    exit(1);
  while ((newline = read_line(fd)))
    {
      if (my_strcmp("##", newline) == 1)
	addlast(rt);
    }
  close(fd);
  if ((fd = open(av[1], O_RDONLY)) == -1)
    exit(1);
  set_obj(rt, fd);
  close(fd);
}
コード例 #8
0
ファイル: jointfind.cpp プロジェクト: goshng/cocoa
void listput(double val, int k)
{
  if (val <= now->v)
  {
    while (val <= now->v && now != first)
      now = now->l; 
    if (now == first && val <= now->v)
      addfirst(val,k);
    else
      addright(val,k);
  }
  else
  {
    while (val > now->v && now != last)
      now = now->r; 
    if (now == last && val > now->v)
      addlast(val,k);
    else
      addleft (val, k);
  }
} // listput
コード例 #9
0
ファイル: LL-EMPLO.C プロジェクト: vikks143/atclib
void main()
{
	 int choice,sal=0,pos;
	 NODE *temp1;
	 char ch;
	 clrscr();
	 while(1)
	 {
	    printf("\n0---->EXIT");
	    printf("\n1---->ADDLAST");
	    printf("\n2---->ADDFIRST");
	    printf("\n3---->DISPLAY");
	    printf("\n4---->EXIT");
	    printf("\n5---->INSERT");
	    printf("\n6---->DELFIRST");
	    printf("\n7---->DEIMIDDLE");
	    printf("\n8---->RIVRESE");
	    printf("\n enter your choice");
	    fflush(stdin);
	    scanf("%d",&choice);
	    switch(choice)
	    {
		case 0:
			exit(0);
		case 1:
			printf("\nenter the salary & name to be inseted in node");
			fflush(stdin);
			scanf("%d%s",&(temp1->sal),temp1->name);
			addlast(temp1);
			break;
		case 2:
			printf("\nenter the salary and name to be inserted in node");
			scanf("%d%s",&temp1->sal,temp1->name);
			addfirst(temp1);
			break;
		case 3:
			display();
			getch();
			break;
		case 4:
			exit(1);
		case 5:
			printf("\nenter the salary,name and position of node to be inseted ");
			fflush(stdin);
			scanf("%d%s%d",&temp1->sal,temp1->name,&pos);
			insert(temp1,pos);
			break;
		case 6:
			delfirst();
			getch();
			break;
		case 7:
			printf("\nenter the position at which node to be deleted");
			scanf("%d",&pos);
			delmid(pos);
			break;
		case 8:
			reverse();
			break;
		default :
			printf("\n you have entered wrong choice");
	      }
	  }
getch();
}
コード例 #10
0
ファイル: main.c プロジェクト: Alecs94/DSA-lab
int main()
{
    FILE *file,*file2;
    file= fopen("input.dat","r");
    file2=fopen("output.dat","w");
    if (file==NULL)
    {
        perror("Cannot read file");
        return -200;
    }
    char line[1000];
    int number;
    while(fscanf(file,"%s",line)!=EOF)
    {

        printf("\n%s",line);
        if(strcmp(line,"AF")==0)
        {
            fscanf(file,"%s",line);
            number=atoi(line);
            addfirst(number);
        }
        if(strcmp(line,"AL")==0)
        {
            fscanf(file,"%s",line);
            number=atoi(line);
            addlast(number);
        }
        if(strcmp(line,"DF")==0)
        {
            deletefirst();
        }
        if(strcmp(line,"DL")==0)
        {
            deletelast();
        }
        if(strcmp(line,"PRINT_ALL")==0)
        {
            printlist(file2);
        }
        if(strcmp(line,"PRINT_F")==0)
        {
            fscanf(file,"%s",line);
            number=atoi(line);
            printleft(number,file2);
        }
        if(strcmp(line,"PRINT_L")==0)
        {
            fscanf(file,"%s",line);
            number=atoi(line);
            printright(number,file2);
        }
        if(strcmp(line,"DE")==0)
        {
            fscanf(file,"%s",line);
            number=atoi(line);
            deletenod(number);
        }
        if(strcmp(line,"DOOM_THE_LIST")==0)
        {
            doom_the_list();
        }
    }

    fclose(file);

    return 0;
}