int main() { int na,nb,i; printf("Enter the numer of terms in the polynomial, then the coefficients and, exponents resp.\n"); scanf("%d",&na); for(i=0;i<na;i++) { scanf("%d%d",&term[i].coef,&term[i].expo); avail++; } finishA=avail-1; startB=avail; printf("Enter the number of terms in the polynomial, then the coefficients and, the exponents resp.\n"); scanf("%d",&nb); for(i=startB;i<nb+startB;i++) { scanf("%d%d",&term[i].coef,&term[i].expo); avail++; } finishB=avail-1; pAdd(); printf("The sum of the two polynomials are:\n"); for(i=startD;i<=finishD;i++) { printf("%dx^%d",term[i].coef,term[i].expo); printf("+"); } printf("0\nEnd"); return 0; }
BOOL CElemCycle::bReadConfig(LPCTSTR pszFileName,CListStream *pListStream) { BOOL bReturn = FALSE; TCHAR szRub[MAX_PATH]; TCHAR szText[MAX_PATH]; int i; int iLastStep; CElemCycleStep *pCycleStep = NULL; RemoveAll(); // label dwGetPrivateProfileString(_T("Config"),_T("Label"),szGetLabel(),szText,sizeof(szText)/sizeof(TCHAR),pszFileName); SetLabel(szText); // duree max bReturn = m_Duration.bSetVal(iGetPrivateProfileInt(_T("Config"),_T("Duration"),0,pszFileName)); // dernier num de pas iLastStep = iGetPrivateProfileInt(_T("Config"),_T("LastStepNum"),0,pszFileName); // trame d'arrêt m_ElemCycleStepStop.bReadConfig(_T("Stop"),pszFileName,pListStream); // les pas for (i = 0;bReturn && (i <= iLastStep); i++) { _stprintf(szRub,_T("%d"),i); if (pCycleStep == NULL) pCycleStep = new CElemCycleStep(); if (bReturn = (pCycleStep != NULL)) { pCycleStep->SetAutoDelete(TRUE); if (pCycleStep->bReadConfig(szRub,pszFileName,pListStream)) { bReturn = (pAdd(pCycleStep) != NULL); pCycleStep = NULL; } else pCycleStep->RemoveAll(); } } if (pCycleStep != NULL) delete pCycleStep; if (!bReturn) { TRACE_DEBUG(eDebug,eCycle,_T(__FILE__),_T(__FUNCTION__),__LINE__,_T("Error: %s"),szGetLabel()); TRACE_DEBUG_IHM(eError,eCycle,eErrorCycleReadConfig); } return bReturn; }