예제 #1
0
ostream& ppsig::print (ostream& fout) const
{
    int 	i;
    double	r;
    Tree 	c, sel, x, y, z, u, var, le, label, id, ff, largs, type, name, file;

    if ( isList(sig) ) 						{
        printlist(fout, sig);
    }
    else if ( isProj(sig, &i, x) ) 					{
        fout << "proj" << i << '(' << ppsig(x, fEnv) << ')';
    }
    else if ( isRec(sig, var, le) )					{
        printrec(fout, var, le, fHideRecursion /*&& (getRecursivness(sig)==0)*/ );
    }

    // debruinj notation
    else if ( isRec(sig, le) )						{
        printrec(fout, le, fHideRecursion );
    }
    else if ( isRef(sig, i) )						{
        fout << "REF[" << i << "]";
    }

    else if ( getUserData(sig) ) 					{
        printextended(fout, sig);
    }
    else if ( isSigInt(sig, &i) ) 					{
        fout << i;
    }
    else if ( isSigReal(sig, &r) ) 					{
        fout << T(r);
    }
    else if ( isSigWaveform(sig) )                  {
        fout << "waveform{...}";
    }
    else if ( isSigInput(sig, &i) ) 				{
        fout << "IN[" << i << "]";
    }
    else if ( isSigOutput(sig, &i, x) ) 			{
        printout(fout, i, x) ;
    }

    else if ( isSigDelay1(sig, x) ) 				{
        fout << ppsig(x, fEnv, 9) << "'";
    }
    //else if ( isSigFixDelay(sig, x, y) ) 			{ printinfix(fout, "@", 8, x, y); 	}
    else if ( isSigFixDelay(sig, x, y) ) 			{
        printFixDelay(fout, x, y);
    }
    else if ( isSigPrefix(sig, x, y) ) 				{
        printfun(fout, "prefix", x, y);
    }
    else if ( isSigIota(sig, x) ) 					{
        printfun(fout, "iota", x);
    }
    else if ( isSigBinOp(sig, &i, x, y) )			{
        printinfix(fout, gBinOpTable[i]->fName, gBinOpTable[i]->fPriority, x, y);
    }
    else if ( isSigFFun(sig, ff, largs) )			{
        printff(fout, ff, largs);
    }
    else if ( isSigFConst(sig, type, name, file) )  {
        fout << tree2str(name);
    }
    else if ( isSigFVar(sig, type, name, file) )    {
        fout << tree2str(name);
    }

    else if ( isSigTable(sig, id, x, y) ) 			{
        printfun(fout, "TABLE", x, y);
    }
    else if ( isSigWRTbl(sig, id, x, y, z) )		{
        printfun(fout, "write", x, y, z);
    }
    else if ( isSigRDTbl(sig, x, y) )				{
        printfun(fout, "read", x, y);
    }
    else if ( isSigGen(sig, x) ) 					{
        fout << ppsig(x, fEnv, fPriority);
    }

    else if ( isSigDocConstantTbl(sig, x, y) )      {
        printfun(fout, "docConstantTbl", x, y);
    }
    else if ( isSigDocWriteTbl(sig, x, y, z, u) )   {
        printfun(fout, "docWriteTbl", x, y, z, u);
    }
    else if ( isSigDocAccessTbl(sig, x, y) )        {
        printfun(fout, "docAccessTbl", x, y);
    }

    else if ( isSigSelect2(sig, sel, x, y) ) 		{
        printfun(fout, "select2", sel, x, y);
    }
    else if ( isSigSelect3(sig, sel, x, y, z) ) 	{
        printfun(fout, "select3", sel, x, y, z);
    }

    else if ( isSigIntCast(sig, x) ) 				{
        printfun(fout, "int", x);
    }
    else if ( isSigFloatCast(sig, x) )				{
        printfun(fout, "float", x);
    }

    else if ( isSigButton(sig, label) ) 			{
        printui(fout, "button", label);
    }
    else if ( isSigCheckbox(sig, label) ) 			{
        printui(fout, "checkbox", label);
    }
    else if ( isSigVSlider(sig, label,c,x,y,z) )	{
        printui(fout, "vslider", label, c, x, y, z);
    }
    else if ( isSigHSlider(sig, label,c,x,y,z) )	{
        printui(fout, "hslider", label, c, x, y, z);
    }
    else if ( isSigNumEntry(sig, label,c,x,y,z) )	{
        printui(fout, "nentry", label, c, x, y, z);
    }
    else if ( isSigVBargraph(sig, label,x,y,z) )	{
        printui(fout, "vbargraph", label, x, y, z);
    }
    else if ( isSigHBargraph(sig, label,x,y,z) )	{
        printui(fout, "hbargraph", label, x, y, z);
    }
    else if ( isSigAttach(sig, x, y) )				{
        printfun(fout, "attach", x, y);
    }

    else {
        cerr << "NOT A SIGNAL : " << *sig << endl;
        //exit(1);
    }
    return fout;
}
예제 #2
0
int main()
{
	int n;
	printf("Enter the total no. of elements in the array.\n");
	scanf("%d",&n);
	int *a = (int *)malloc(sizeof(int) * n);
	printf("Enter the elements of the array.\n");
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}

	mainchoices();

	int ch;
	scanf("%d",&ch);
	while(ch!=-1)
	{
		if(ch==1)
		{
			changechoices();
			int chch;
			scanf("%d",&chch);
			if(chch==1)
			{
				printf("\nEnter the index no. Remember that indexing starts from 0 in the array.\n\n");
				int ind,value;
				scanf("%d",&ind);
				if(ind<n && ind>=0)
				{
					printf("\nEnter the new value.\n");
					scanf("%d",&value);
					updateByIndex(a,ind,value);
					printf("Updated the value of index no %d to %d\n",ind,value);
				}
				else
				{
					printf("This index does not exist. Please choose an index between 0 to %d both inclusive.\n",n-1);
					mainchoices();
				}
			}

			else if(chch==2)
			{
				printf("\nEnter the old value followed by the new value.\n\n");
				int oldv,newv;
				scanf("%d%d",&oldv,&newv);
				int in=search(a,oldv,n);
				if(in<n)
				{
					a[n]=newv;
					printf("Updated value at the ind no. %d to %d.\n",in,newv);
				}
				else
				{
					printf("This value is not present in the array.\n");
					mainchoices();
				}
			}

			else
			{
				printf("\nYour choice doesn't match any of the available options\n");
				mainchoices();
			}
		}

		else if(ch==2)
		{
			deletechoices();
			int chdel;
			scanf("%d",&chdel);
			if(chdel==1)
			{
				int ind;
				printf("\nEnter the index to be deleted.Remember that indexing starts from 0.\n");
				scanf("%d",&ind);
				if(ind<n)
				{
					n=deleteindex(a,ind,n);
					printf("\n\nDeleted index no %d. New size of the array is %d\n",ind,n);
				}
				else
				{
					printf("\n%d index is out of the array size.\n",ind);
					mainchoices();
				}
			}

			else if(chdel==2)
			{
				printf("Enter the element value to be deleted.\n");
				int del;
				scanf("%d",&del);
				int ind=search(a,del,n);
				if(ind<n)
				{
					n=deleteindex(a,ind,n);
					printf("\nDeleted element %d. New size of the array is %d\n",del,n);
				}
				else
				{
					printf("\n%d is not present in the array, hence can't be deleted.\n",del);
				}
			}

		}

		else if(ch==3)
		{
			printf("Enter the value of the elem] to be searched in the array.\n");
			int val;
			scanf("%d",&val);
			int fo=search(a,val,n);
			if(fo<n)
			{
				printf("%d is present at the index %d.\n",val,fo);
			}
			else
			{
				printf("%d is not present in the array\n",val);
			}
		}

		else if(ch==4)
		{
			printfun(a,n);
		}

		else if(ch==5)
		{
			printf("size of the array is %d\n",n);
		}

		else
		{
			printf("None of the choices you eneterd matches the given choices.\n");
			mainchoices();
		}
		mainchoices();
		scanf("%d",&ch);
	}

}