void XMLWriter::startElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes) { if (_depth == 0 && !_inFragment && _elementCount > 1) throw XMLException("Not well-formed. Second root element found", nameToString(localName, qname)); if (_unclosedStartTag) closeStartTag(); prettyPrint(); writeStartElement(namespaceURI, localName, qname, attributes); _elementStack.push_back(Name(qname, namespaceURI, localName)); _contentWritten = false; ++_depth; }
void XMLWriter::emptyElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes) { if (_depth == 0 && _elementCount > 1) throw XMLException("Not well-formed. Second root element found."); if (_unclosedStartTag) closeStartTag(); prettyPrint(); writeStartElement(namespaceURI, localName, qname, attributes); _contentWritten = false; writeMarkup("/"); closeStartTag(); }
void prettyPrint(t_btree *root,int recLevel) //! root, index, length, reccurence level { if(root==NULL) { recLevel--; //! reached leaf, must decrement recurence level return; } recLevel++; //! otherwise increment it prettyPrint(root->right,recLevel); //! keep going right in the tree int j=0; //! print spaces for the appropriate recurence level for(j=0; j<recLevel-1; j++) { fprintf(g, " "); } //! then print value printElement(root); //! print a new line fprintf(g, "\n"); prettyPrint(root->left,recLevel); //! keep going left in the tree }
int main() { nodet *root=createNode(10); root=insert(root,4); root=insert(root,20); root=insert(root,40); root=insert(root,25); root=insert(root,1); prettyPrint(root,0); printf("\n %d",isBST(root)); return 0; }
int main() { nodeT *root=createStaticBinTree(); nodeL *head=createListFromTree(root); printf("The list from the tree:\n"); printAll(head); printf("The tree from the list:\n"); root=createTreeFromList(); //inorder(root); prettyPrint(root,0); return 0; }
// Prints out the polynomial void printPolynomial(int max_d, int co[]) { printf("The polynomial is "); int head = NULL; // Denotes the first non-zero coefficient // Finds the first non-zero coefficient for (int i = 0; i < max_d; i++) { if (co[i] != 0) { head = i; break; } } prettyPrint(max_d, head, co); }
int main (int argc, char **argv) { int c; ATerm bottomOfStack; PT_ParseTree parsetree; ATerm ambiguities; ATbool atermformat = ATfalse; char *input_file_name = "-"; char *output_file_name = "-"; while ((c = getopt(argc, argv, myarguments)) != EOF) switch (c) { case 'a': atermformat = ATtrue; break; case 'h': usage(); exit(0); case 'i': input_file_name = optarg; break; case 'o': output_file_name = optarg; break; case 'V': fprintf(stderr, "%s %s\n", myname, myversion); exit(0); default : usage(); exit(1); } ATinit(argc, argv, &bottomOfStack); /* Initialize Aterm library */ PT_initMEPTApi(); parsetree = PT_ParseTreeFromTerm(ATreadFromNamedFile(input_file_name)); if(parsetree == NULL) { ATerror("%s: could not read term from input file %s\n", myname, input_file_name); } ambiguities = PT_reportParseTreeAmbiguities(parsetree); if(!atermformat) { FILE *fp = NULL; if(!strcmp(output_file_name, "") || !strcmp(output_file_name,"-")) { fp = stdout; } else if(!(fp = fopen(output_file_name, "wb"))) { ATerror("%s: could not open %s for output.\n", myname, output_file_name); return 1; } prettyPrint(ambiguities,fp); fclose(fp); } else { ATwriteToNamedTextFile(ambiguities, output_file_name); } return 0; }
int main() { root=createBinTree(); head=getLfromT(root); printf("tree=>list: \n"); printList(); delTree(root); root=NULL; root=getTfromL(&head); printf("list=>tree: \n"); prettyPrint(root,0); return 0; }
void prettyPrint(nodeT *root,int recLevel) { if(root==NULL) { recLevel--; return; } recLevel++; prettyPrint(root->right,recLevel); int j=0; for(j=0; j<recLevel-1; j++) { printf(" "); } printf("%d", root->data); printf("\n"); prettyPrint(root->left,recLevel); }
int main() { FILE* f=fopen("input.txt", "r"); if(f==0) printf("err"); NodeT *root=createBinaryTree(f); printf("Initial tree:\n"); prettyPrint(root, 0); printf("\nList:\n"); NodeL *head=ListFromTree(root); printList(head); printf("\nFinal tree:\n"); root=TreeFromList(&head); prettyPrint(root, 0); fclose(f); return 0; }
int main() { input=fopen("input.dat", "r"); output=fopen("output.dat","w"); NodeT *root = createBinTree(); NodeL *firstFromList = getListFromTree(root); traverseList(firstFromList); root=getFromList(&firstFromList); prettyPrint(root, 0); return 0; }
int main() { FILE *in; in=fopen("input.txt", "r"); createQ(in); NodeT *root = createTree(); prettyPrint(root, 0); return 0; }
static void printCFGRootedAt(const CFGNode *root, FILE *f, std::set<const CFGNode *> &done, const std::vector<std::pair<StateMachine::entry_point, StateMachine::entry_point_ctxt> > &roots) { if (!done.insert(root).second) return; std::map<unsigned, StateMachine::entry_point_ctxt> rootOf; for (auto it = roots.begin(); it != roots.end(); it++) { if (root == it->first.node) { rootOf.insert(std::pair<unsigned, StateMachine::entry_point_ctxt>(it->first.thread, it->second)); } } if (!rootOf.empty()) { int printed = 1; fprintf(f, "-"); for (auto it = rootOf.begin(); it != rootOf.end(); it++) { if (it != rootOf.begin()) { printed += fprintf(f, ","); } printed += fprintf(f, "%d:%s", it->first, it->second.name()); } if (printed < 9) { char buf[] = "----------"; fprintf(f, "%.*s", 9 - printed, buf); } fprintf(f, "->"); } else { fprintf(f, ".%10s", ""); } fprintf(f, "%s: %s", root->label.name(), root->rip.name()); std::vector<CFGNode *> successors; bool done_one = false; for (auto it = root->successors.begin(); it != root->successors.end(); it++) { if (it->instr == NULL) continue; if (done_one) fprintf(f, ", "); else fprintf(f, " -> "); done_one = true; it->prettyPrint(f); successors.push_back(it->instr); } fprintf(f, "\n"); for (auto it = successors.begin(); it != successors.end(); it++) printCFGRootedAt(*it, f, done, roots); }
int main(void) { t_btree *root, *rootFromList; f = fopen("input.dat", "r"); g = fopen("output.dat", "w"); root = createBinTree(); getListFromTree(root); traverseList(head); rootFromList = getTreeFromList(); prettyPrint(root, 0); fprintf (g, "\n"); return (0); }
int main() { NodeT* root=NULL; FILE* f=fopen("input.txt", "r"); if(f==0) printf("err"); root=createBinaryTree(f); printf("Initial tree:\n"); prettyPrint(root, 0); printf("\n\n\n"); int vvalue; for(vvalue=1; vvalue<=100; vvalue++) if(searchNode(root, vvalue)==0)//this line is only for making sure that a value is not inserted 2 times root=insertNodeAVLtree(root, vvalue); prettyPrint(root, 0); fclose(f); return 0; }
int main() { FILE *p; NodeT *root=NULL; p=fopen("input.txt","r"); int data; while(!feof(p)) { fscanf(p,"%d",&data); root=Insert(root,data); } printf("\n"); prettyPrint(root,0); return 0; }
void XMLWriter::processingInstruction(const XMLString& target, const XMLString& data) { if (_unclosedStartTag) closeStartTag(); prettyPrint(); writeMarkup("<?"); writeXML(target); if (!data.empty()) { writeMarkup(MARKUP_SPACE); writeXML(data); } writeMarkup("?>"); if (_depth == 0) writeNewLine(); }
int main(int argc, char **argv) { int **arr, rows, cols; int i, j; arr = prettyPrint(5, &rows, &cols); for (i = 0; i < rows; i++) { for (j = 0; j < cols; j++) { printf("%d ", arr[i][j]); } printf("\n"); } return (0); }
QString Utilities::prettyPrint(const QVariantList & array) { QString res; res.append("{\n"); for (int i = 0; i < array.size(); ++i) { res.append(prettyPrint(array.at(i))); if (i < array.size() - 1) res.append(","); } res.append("}\n"); return res; }
int main() { NodeT *root = NULL; root = insertNode(root,1); root = insertNode(root,2); root = insertNode(root,3); root = insertNode(root,4); root = insertNode(root,5); root = insertNode(root,6); root = insertNode(root,7); root = insertNode(root,8); root = insertNode(root,9); root = insertNode(root,10); prettyPrint(root, 0); return 0; }
int main() { FILE *f=fopen("input.txt","r"); if(f==NULL) { perror("Can't open file!\n"); return -1; } NodeT *root=createBinTree(f); AVLTree(root); root=insertNode(root,11); root=deleteNode(root,11); prettyPrint(root,0); return 0; }
void XMLWriter::endElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname) { if (_depth < 1) throw XMLException("No unclosed tag"); if (!_elementStack.back().equalsWeakly(qname, namespaceURI, localName)) throw XMLException("End tag does not match start tag", nameToString(localName, qname)); _elementStack.pop_back(); --_depth; if (!_unclosedStartTag) prettyPrint(); writeEndElement(namespaceURI, localName, qname); _contentWritten = false; if (_depth == 0) writeNewLine(); }
int main(void) { TreeT *root; FILE *f; f = fopen("input.txt", "r+"); if (f == NULL) { perror("Cannot open file"); return(-1); } root = createBinTree(f); printf("The tree made from the input is : \n"); prettyPrint(root, 0); return 0; }
void printPodSimply(const TeamDB& teamDB, const std::map<Reference<Team>, double>& scoreReport, const std::string& prefix = "") { // Sort by scores std::vector<Reference<Team>> sortedTeams; for (auto entry: scoreReport) { sortedTeams.push_back(entry.first); } auto sorter = [&scoreReport](Reference<Team> a, Reference<Team> b){ return scoreReport.find(a)->second > scoreReport.find(b)->second; }; std::sort(sortedTeams.begin(), sortedTeams.end(), sorter); for (auto team : sortedTeams) { std::cout << prefix; prettyPrint(std::cout, scoreReport.find(team)->second); std::cout << " " << teamDB.read(team)->name << "\n"; } }
int main() { FILE *file, *fileOutput; file= fopen("input.dat", "r"); if(file== NULL) { perror("Cannot open file"); return -100; } fileOutput = fopen("output.dat", "w"); getContent = &getStringContent; printElement = &printStringElement; NodeT *root = NULL; root = createBinTree(file); prettyPrint(root,0,fileOutput); return 0; }
// Prints out the derivative void printDerivative(int max_d, int co[]) { printf("Its derivative is "); int de[10]; // Array to store the coefficients of the derivative int head = NULL; for (int i = 0; i < max_d; i++) { de[i] = co[i] * (max_d - i); } // Finds the first non-zero coefficient for (int i = 0; i < max_d; i++) { if (co[i] != 0) { head = i; break; } } if (max_d == 0) { printf("0\n"); } else { prettyPrint(max_d-1, head, de); } }
/* Main-Funktion */ int main(int argc, char *argv[]) { // Zufallszahlengenerator initialisieren srand(time(NULL)); matrix a = initMatrixRand(5,5); matrix b = initMatrixRand(5,5); printf("a =\n"); prettyPrint(a); printf("\nb =\n"); prettyPrint(b); matrix c = addMatrix(a, b); printf("\na + b =\n"); prettyPrint(c); freeMatrix(c); c = subMatrix(a, b); printf("\na - b =\n"); prettyPrint(c); freeMatrix(c); c = multMatrix(a, b); printf("\na * b =\n"); prettyPrint(c); freeMatrix(c); c = transposeMatrix(a); printf("\na^T =\n"); prettyPrint(c); freeMatrix(c); printf("\ndet(a) = %.2f\n", determinante(a)); printf("detQuick(a) = %.2f\n\n", detQuick(a)); printf("\ndet(b) = %.2f\n", determinante(b)); printf("detQuick(b) = %.2f\n\n", detQuick(b)); freeMatrix(a); freeMatrix(b); return 0; }
void moveCommand(field f, location from, direction d) { printf("%s\n", doMove(f, from, d) >= 0 ? prettyPrint(f) : "Illegal move!\n"); }
void Unit::prettyPrint(std::ostream &out) const { prettyPrint(out, 0, m_bclen); }
int main(int argc, const char * argv[]) { FILE *filePointer; char fileName[100]; char inputNumber[20]; int isValidFile = FALSE; int playAgain = FALSE; int node; int nodeCounter = 0; // loops until user enters a valid file while (!isValidFile) { printf("Enter a file name: "); scanf("%s", fileName); filePointer = fopen(fileName, "rt"); if (filePointer == NULL) { printf("Could not open the file! Try again!\n"); } else { isValidFile = TRUE; while (fscanf(filePointer, "%d", &node) == 1){ add(node); nodeCounter++; } fclose(filePointer); } } // If no nodes were added from the file, quit the program if (nodeCounter == 0) { printf("The file was empty! No nodes were added!\nExiting the program!\n"); return EXIT_SUCCESS; } prettyPrint(); // loops until user wants to delete more nodes // or there are remaining nodes to delete while(!playAgain) { printf("Enter a number to delete: "); scanf("%s", inputNumber); int deleteNode = atoi (inputNumber); BOOLEAN isFound = delete(deleteNode); if (isFound) { printf("Number %d was deleted!\n", deleteNode); nodeCounter--; } else { printf("Number %d was not found!\n", deleteNode); } prettyPrint(); if (nodeCounter == 0) { printf("No more nodes remaining! Exiting the program!\n"); playAgain = TRUE; } else if (!deleteAgain()) { playAgain = TRUE; } } return EXIT_SUCCESS; }