コード例 #1
0
void AView::read(QDomNode &element)
{
  QDomNodeList nodeList = element.childNodes();

  for(int i = 0; i < nodeList.count(); ++i) {
    QDomNode node = nodeList.item(i);
    if(!node.isElement())
      continue;
    QDomElement element = node.toElement();

    QString name = node.nodeName();
    AView* newView = createView(name, this);
    if(!newView)
      continue;
    childs.append(newView);
    newView->read(element);
  }

    QDomElement e = element.toElement();
    id = e.attribute("android:id");
    id = explodeName(id);
    id = captializeName(id);

    width = QString::number(atof(qPrintable(e.attribute("android:layout_width"))));
    height = QString::number(atof(qPrintable(e.attribute("android:layout_height"))));
}
コード例 #2
0
void UvaErdo(){
	int scenarios, papers, names;
	int scenario, paper, nameInd;
	int scanfreturnvalue;
	
	scanfreturnvalue = scanf("%d", &scenarios);
	for (scenario = 1; scenario <= scenarios; scenario++){
		//~ printf("Scenario %d\n", scenario);
		scanfreturnvalue = scanf("%d %d\n", &papers, &names);
		scanfreturnvalue = scanfreturnvalue / 2;
		
		char *ptr;
		ptr = (char*)malloc(sizeof(char) * MAX_INPUT_LEN);
		for (paper = 1; paper <= papers ; paper++){
			char *paperAuthors;
			paperAuthors = ptr;
			
			scanfreturnvalue = scanf("%[^:]s\n", paperAuthors);
			while ( getchar() != '\n');
			
			char lname[MAX_NAME_LEN], fname[MAX_NAME_LEN];
			Author *authors[MAX_PAPER_AUTHORS];
			int authorsIndex = 0;
			
			while (paperAuthors[0] != '\0') {
				paperAuthors = explodeName(paperAuthors, fname, lname);
				//~ printf("\t'%s' => '%s', '%s'\n", paperAuthors, lname, fname);
				
				authors[authorsIndex] = Author::findAuthor(fname, lname);
				if (authors[authorsIndex] == NULL){
					if (strlen(lname) == 0 || strlen(fname) == 0){
						continue;
					}
					authors[authorsIndex] = new Author{lname, fname};
				}
				authorsIndex++;
			}
			
			for (int i = 0; i < authorsIndex; i++){
				for (int j = 0; j < authorsIndex; j++){
					authors[i]->publicouCom(authors[j]);
				}
			}
			ptr = (char*) memset(ptr, 0, sizeof(char) * MAX_INPUT_LEN);
		}
		
		printf("Scenario %d\n", scenario);
		std::list<Author*> *targets = new std::list<Author*>;
		std::list<std::string*> *targetsNames = new std::list<std::string*>;
		for (nameInd = 1; nameInd <= names; nameInd++){
			char lname[MAX_NAME_LEN], fname[MAX_NAME_LEN], bigname[MAX_INPUT_LEN];
			Author *a;
			scanfreturnvalue =  scanf("%[^\n]s\n", bigname);
			while ( getchar() != '\n');
			explodeName(bigname, fname, lname);
			//~ printf("\t'%s' => '%s', '%s'\n", bigname, lname, fname);
			
			std::string *bigstring = new std::string(bigname);
			targetsNames->push_back(bigstring);
			a = Author::findAuthor(fname, lname);
			if (a == NULL){
				continue;
			} else {
				//~ printf("'%s' lname\n", a->lname.c_str());
				targets->push_back(a);
			}
		}
		
		//~ if (Author::erdosPtr != NULL){
			//~ Author::erdosPtr->process(targets);
			//~ printf("Author::erdosPtr not NULL\n");
		//~ }
		
		std::list<std::string*>::iterator iNames = targetsNames->begin();
		for (std::list<Author*>::iterator a = targets->begin();
			a != targets->end() && iNames != targetsNames->end();
			a++
		){
			if ((*a) == NULL){
				printf("%s infinity\n", (*iNames)->c_str());
			} else {
				int d = (*a)->depht;
				if (d <= 0 && Author::erdosPtr != (*a)){
					printf("%s, %s infinity\n", (*a)->lname.c_str(), (*a)->fname.c_str());
				} else {
					printf("%s, %s %d\n", (*a)->lname.c_str(), (*a)->fname.c_str(), d);
				}
			}
			fflush(stdout);
			
			iNames++;
		}
		
		for (
			std::list<std::string*>::iterator i = targetsNames->begin();
			i != targetsNames->end();
			i++
		){
			delete *i;
		}
		
		delete targets;
		delete targetsNames;
		freeMemory();
	}
}