예제 #1
0
QJsonObject ICQuestion::saveAsJsonObject() const
{
    QJsonObject jo;
    jo.insert(idTag, QJsonValue(getId()));
    jo.insert(typeTag, QJsonValue(getType()));
    if (!getChoices().isNull())
        jo.insert(choicesTag, QJsonValue(getChoices()));

    return jo;
}
예제 #2
0
int dp(node* dict, char prefix[], char suffix[], int n) {
  if (!suffix[0]) {
    if (lookup(dict, prefix))
      return n;
    else
      return 0;
  }

  if (n <= 0)
    return 0;

  if (doubleLookup(dict, prefix, suffix))
    return n;

  char choices[ALPHABET_SIZE];
  int nchoices, i, j, result;
  nchoices = i = j = result = 0;

  getChoices(dict, prefix, choices, &nchoices);

  int results[2 + 2 * nchoices];
  results[i++] = accept(dict, prefix, suffix, n);
  results[i++] = delete(dict, prefix, suffix, n);

  for (j = 0; j < nchoices; ++j)
    results[i++] = swap(dict, prefix, suffix, n, choices[j]);

  for (j = 0; j < nchoices; ++j)
    results[i++] = insertChar(dict, prefix, suffix, n, choices[j]);

  for (i = 0; i < 2 + 2 * nchoices; i++)
    result = results[i] > result ? results[i] : result;

  return result;
}
예제 #3
0
static void do_apply(void)
{
    struct structGUI newGUI;

    getChoices(&newGUI);
    applyGUI(&newGUI);
}
예제 #4
0
파일: tobias.cpp 프로젝트: mittwinter/ae
bool Tobias::solve( size_t max, size_t slot, size_t student ) {
	//std::clog << slot << "," << student << "..." << std::endl;
	if( student == getNames().size() ) {
		slot++;
		student = 0;
	}
	if( avaiableSlots() == 0 || slot >= slots() ) {
		//std::cerr << (*this) << std::endl;
		return isSolved( max );
	}
	//std::clog << "!" << !slotFull( slot, max ) << std::endl;
	//std::clog << ">" << getChoices().at( student * slots() + slot ) << std::endl;
	//std::clog << "+" << !isStudentScheduled( student ) << std::endl;
	if( getReference().at( slot ) && !slotFull( slot, max ) && getChoices().at( student * slots() + slot ) && !isStudentScheduled( student ) ) {
		schedule[ student * slots() + slot ] = true;
		//std::clog << "Trying schedule[" << student << "," << slot << "] = true..." << std::endl;
		if( solve( max, slot, student + 1 ) ) {
			return true;
		}
		schedule[ student * slots() + slot ] = false;
	}
//	else {
		return solve( max, slot, student + 1 );
//	}
	return false;
}
예제 #5
0
파일: IMEAppDlg.cpp 프로젝트: amitdo/Lipitk
void CIMEAppDlg::recognizeStrokes(void)
{
	displayMessage(L"Recognizing...");

	if(0 != m_PenPointsVec.size())
	{
		vector<CString> topchoices;
		vector<LTKShapeRecoResult> resultSet;
		if( FAILURE == m_ShapeRecognizer.recognize(m_penstrokes,MAX_CHOICE,resultSet))
		{
			displayMessage(L"Wrong gesture!");
			return;
		}
		
		vector<CString> topChoices;
		if(m_IsMappingFileFound)
			getChoices(resultSet,topChoices);
		else
		{
			int iIndex = 0;
			for(vector<LTKShapeRecoResult>::iterator t = resultSet.begin(); 
						t < resultSet.end() && iIndex < MAX_CHOICE; t++,iIndex++)
			{
				CString displayValue;
				displayValue.Format(L"%d",(*t).getShapeId());
				m_DisplayChoice[iIndex].SetWindowTextW(displayValue);
				UpdateData(false);
			}
			topChoices.clear();
		}

		if(topChoices.size() != 0)
		{
			for(int i=0;i<MAX_CHOICE && i< (int)topChoices.size();i++)
			{
				long choice=0;
				if(topChoices[i].Find(L"0X") != -1 || topChoices[i].Find(L"0x") != -1)
				{
					choice = (long)_tcstol(topChoices[i].GetBuffer(topChoices[i].GetLength()),NULL,16);
				}
				else
				{
					topChoices[i].Trim(L" ");
					choice = (long)topChoices[i].GetAt(0);
				}
				displayChoice(m_DisplayChoice[i].m_hWnd,(TCHAR)choice);
			}
		}
		displayMessage(L" ");

	}
}
예제 #6
0
static void load(button b) /* button callback */
{
    char *optf, buf[256];
    struct structGUI newGUI;

    setuserfilter("All files (*.*)\0*.*\0\0");
    strcpy(buf, getenv("R_USER"));
    R_fixbackslash(buf);
    optf = askfilenamewithdir(G_("Select 'Rconsole' file"), "Rconsole", buf);
    if(!optf) return;

    getChoices(&newGUI);
    if (loadRconsole(&newGUI, optf)) {
        if (strlen(newGUI.warning)) askok(newGUI.warning);
	cleanup();
	showDialog(&newGUI);
    }
}
예제 #7
0
파일: libSIDT.cpp 프로젝트: yaps8/griso
char* drawDN(decisionNode* dn, int prof, char withLabels){
	char* s=makeDotNode(dn, prof);
	int i=0;

	if (dn->ht!=NULL){
		listDecisionNode* listdn=getChoices(dn->ht);
		char** strList=NULL;
		int nStr = 0;
		int tailleT=0;
		for (i=0; i<listdn->taille;i++){
			decisionNode* dnp=listdn->ldn[i];
			char* c=drawDN(dnp, prof+1, withLabels);
			tailleT+=strlen(c);
			nStr++;
			strList = (char**) realloc(strList, nStr*sizeof(char*));
			strList[nStr-1]=c;

			char* c2=makeDotEdge(dn, dnp, listdn->value1[i], listdn->value2[i], listdn->label[i], withLabels);
			tailleT+=strlen(c2);
			nStr++;
			strList = (char**) realloc(strList, nStr*sizeof(char*));
			strList[nStr-1]=c2;
		}

		char* ret= (char*) malloc(sizeDotNode+nStr*sizeDotEdge+tailleT);
		sprintf(ret, "%s\0", s);

		for (i=0; i<nStr;i++){
			strcat(ret, strList[i]);
		}
		return ret;
	}
	else {
		return s;
	}
}