Пример #1
0
int make_choice(char choice, int* matrixA, int* matrixB, int* result , int size){
	int scale_factor = 0;
	switch (choice)
	{
	case 'A': case 'a':
		_add(matrixA,matrixB,result,size);
		print_square_matrix(result, size);
		break;
	case 'S': case 's':
		printf("Result of Matrix1's Sum = %d", sum(matrixA, size));
		break;
	case 'M': case 'm':
		mult(matrixA,matrixB,result,size);
		print_square_matrix(result,size);
		break;
	case 'C': case 'c':
	    printf("Enter scale factor: "); 
	    scanf("%d", &scale_factor); getc(stdin);
	    printf("\n");
		scale(matrixA, scale_factor, result, size);
		print_square_matrix(result, size);
		break;
	case 'Q': case 'q':
		square(matrixA,result,size);
		print_square_matrix(result,size);
		
		break;
	case 'B': case 'b':
		if(size<11 || size > 80){
		printf("Size is not between 11 and 80");
	}
		else{
		itu(matrixA,size);
		print_square_matrix(matrixA,size);
	}
		break;
	case 'E': case 'e':
		return 0;
	default:
		break;
	}
	printf("\n");
	return 1;
}
Пример #2
0
void BrowserView::update(const Q3PtrList<BrowserView> & lv)
{
  Q3Dict<Use> all_nodes(DICT_SIZE);
  Q3PtrListIterator<BrowserView> itv(lv);
  
  all_nodes.setAutoDelete(TRUE);
  
  // look at the revision in each view
  
  for (; itv.current(); ++itv) {
    Q3DictIterator<BrowserNode> itd(itv.current()->nodes);

    for (; itd.current(); ++itd) {
      BrowserNode * bn = itd.current();
      int rev = bn->get_rev();
      Use * use = all_nodes.find(itd.currentKey());
      
      if (use == 0)
	all_nodes.insert(itd.currentKey(), new Use(rev));
      else {
	if (rev < use->rev_min)
	  use->rev_min = rev;
	if (rev > use->rev_max)
	  use->rev_max = rev;
	use->count += 1;
      }
    }
  }
  
  // first solve step
  // only the package existing in all the view are solved
  
  int nviews = lv.count();
  QStringList deleted_or_new;
  
  Q3DictIterator<Use> itu(all_nodes);
  
  for (; itu.current(); ++itu) {
    QString who = itu.currentKey();
    Use * use = itu.current();
	    
    if (use->count == nviews) {
      // exist in all views : solve the state
      if (use->rev_min == use->rev_max) {
	// up to date in all views
	for (itv.toFirst(); itv.current(); ++itv)
	  itv.current()->nodes.find(who)->set_state(UpToDate);
      }
      else {
	int max = use->rev_max;
	
	for (itv.toFirst(); itv.current(); ++itv) {
	  BrowserNode * pack = itv.current()->nodes.find(who);
	  
	  pack->set_state((pack->get_rev() == max) ? Young : Old);
	}
      }
    }
    else {
      // deleted or new, mark it unknown for this step
      deleted_or_new.append(who);
      
      for (itv.toFirst(); itv.current(); ++itv) {
	BrowserNode * pack = itv.current()->nodes.find(who);
	
	if (pack != 0)
	  pack->set_state(Unknown);
      }
    }
  }
  
  all_nodes.clear();
  
  // solve packages marked unknown
  // a package is deleted if its parent is never 'Young'
  
  QStringList::Iterator it;
  
  for (it = deleted_or_new.begin(); it != deleted_or_new.end(); ++it) {
    QString who = *it;
    Q3PtrList<BrowserNode> images;
    bool young = FALSE;
    
    // set the state in each view without looking at the others
    for (itv.toFirst(); itv.current(); ++itv) {
      BrowserNode * pack = itv.current()->nodes.find(who);
      
      if (pack != 0) {
	images.append(pack);
	if (pack->solve())
	  young = TRUE;
      }
    }
    
    // set the final state if young, else all already marked deleted
    if (young) {
      BrowserNode * pack;
      
      for (pack = images.first(); pack != 0; pack = images.next())
	pack->set_state(Young);
    }
  }
  
  // force update on views
  for (itv.toFirst(); itv.current(); ++itv)
    itv.current()->update_it();
}
Пример #3
0
void UcUseCaseCanvas::send(ToolCom * com, Q3CanvasItemList & all)
{
  Q3PtrList<UcUseCaseCanvas> lu;
  Q3PtrList<UcClassCanvas> la;
  Q3CanvasItemList::Iterator cit;

  for (cit = all.begin(); cit != all.end(); ++cit) {
    DiagramItem *di = QCanvasItemToDiagramItem(*cit);
    
    if ((di != 0) && (*cit)->visible()) {
      switch (di->type()) {
      case UmlUseCase:
	lu.append((UcUseCaseCanvas *) di);
	break;
      case UmlClass:
	la.append((UcClassCanvas *) di);
	break;
      default:
	break;
      }
    }
  }
  
  // send UC
  
  com->write_unsigned(lu.count());
  
  Q3PtrListIterator<UcUseCaseCanvas> itu(lu);
  
  for (; itu.current(); ++itu) {
    com->write_unsigned((unsigned) itu.current()->get_ident());
    itu.current()->get_bn()->write_id(com);
    com->write(itu.current()->rect());
  }
  
  // send Actors
  
  com->write_unsigned(la.count());
  
  Q3PtrListIterator<UcClassCanvas> ita(la);
  
  for (; ita.current(); ++ita)
    ita.current()->get_bn()->write_id(com);
  
  // send rels
  
  Q3PtrList<ArrowCanvas> lr;
  
  for (itu.toFirst(); itu.current(); ++itu) {
    Q3PtrListIterator<ArrowCanvas> itl(itu.current()->lines);
    
    for (; itl.current(); ++itl) {
      ArrowCanvas * r = itl.current();
      DiagramItem * from = r->get_start();
      DiagramItem * to = r->get_end();
      
      if ((from->type() == UmlUseCase)
	  ? (to->type() == UmlClass)
	  : (from->type() == UmlClass))
	lr.append(r);
    }
  }
  
  com->write_unsigned(lr.count());
  
  Q3PtrListIterator<ArrowCanvas> itr(lr);
  
  for (; itr.current(); ++itr)
    itr.current()->write_uc_rel(com);
}