void printUp(binTree *root)
{
    if (root == NULL)
    {
        return;
    }
    printUp(root->left);
    printf("%d ", root->value);
    printUp(root->right);
    return;
}
Exemple #2
0
int main (int    argc,
	  char** argv)
// ---------------------------------------------------------------------------
// Driver for other routines.
// ---------------------------------------------------------------------------
{
  Action         mirror = UNDEFINED;
  Point          axis;
  real_t         angle = 0.;
  int_t          nvert, nel;	// -- Numbers read from input.
  int_t          nrep = 1;	// -- Number of times to repeat operation.
  vector<Node*>  vertices;
  vector<Node*>* elements;
  FEML*          F;

  Femlib::initialize (&argc, &argv);

  getArgs (argc, argv, mirror, axis, angle, nrep, F);

  nvert = getVertices (F, vertices, mirror, axis, angle, nrep);
  nel   = getElements (F, vertices, elements, nvert, nrep);

  printUp  (cout, const_cast<const vector<Node*>&>(vertices),
	    const_cast<const vector<Node*>*&>(elements),
	    nvert, nel, nrep, mirror);

  Femlib::finalize();
  
  return EXIT_SUCCESS;
}
Exemple #3
0
int main()
{	
	setlocale(LC_ALL, "Rus");
	Node* root = NULL;
	int operation = 0;
	int el = 0;
	operations();
	while (true)
	{
	    printf("Выберите действие: ");
	    scanf("%d", &operation);
		switch (operation)
		{
		    case 1:
	        {
	            printf("Введите значение\n");
	            scanf("%d", &el);
	            add(root, el);
			    break;
	        }
		    case 2:
	        {
		        printf("Введите значение\n");
	            scanf("%d", &el);
			    remove(root, el);
			    break;
	        }
		    case 3:
	        {
		        printf("Введите значение\n");
	            scanf("%d", &el);
		        if (find(root, el) != NULL)
			        printf("Элемент принадлежит множеству\n");
				else
			        printf("Элемент не принадлежит множеству\n");
			    break;
	        }
		    case 4:
		    {
		        printUp(root);
				break;
		    }
		    case 5:
		    {
			    printDown(root);
			    break;
			}
		    case 0:
		    {
			    exit(root);
			    return 0;
				break;
		    }
		}
	}
}
int main()
{
    binTree* root = NULL;
    int i = 0;
    while(i == 0)
    {
        char c;
        int cur;
        scanf("%c", &c);
        switch (c)
        {
            case 'a':
                scanf("%d", &cur);
                root = addElement(root, cur);
            break;
            case 'r':
                scanf("%d", &cur);
                root = removeElement(root, cur);
            break;
            case 'i':
                scanf("%d", &cur);
                if(hasElement(root, cur) == 0)
                {
                        printf("Element doesn't belong to tree\n");
                }
                else
                {
                        printf("Element belongs to tree\n");
                }
            break;
            case 'p':
                printParenthesis(root);
                printf("\n");
            break;
             case 'u':
                printUp(root);
                printf("\n");
            break;
             case 'd':
                printDown(root);
                printf("\n");
            break;
            case 'c':
                clearTree(root);
                i = 1;
            break;
        }
    }
    return 0;
}