int CBwfind::valuefirst(int tb[][8] ) { int flag,minus,corner=0,v,ComMobil,ManMobil,DiffMobil,Num,squre; int danger; flag=ComChoice; ComMobil=Mobility(tb,ComChoice); ManMobil=Mobility(tb,ManChoice); //DiffMobil=ComMobil*ComMobil-ManMobil*ManMobil; //a DiffMobil=ComMobil-ManMobil; //b Num=Total(tb); if(flag==1){ minus=white(tb)-black(tb); if(minus>=0) squre=minus*minus; else squre=-minus*minus; danger=black(tb); } if(flag==-1){ minus=black(tb)-white(tb); if(minus>=0) squre=minus*minus; else squre=-minus*minus; danger=white(tb); } if(Num<25){ v=minus+2*DiffMobil; } else{ v=minus+3*DiffMobil; } if(danger==0) v=-10000; return v; }
double PullUp::CaloriesBurned() const { // work (joules) = force (newtons) * displacement (meters) double massKg = m_athlete.GetWeightKg() + AdditionalWeightUsedKg(); double distanceM = (double)0.25; double caloriesPerRep = massKg * distanceM * CALORIES_PER_JOULE; return (double)Total() * caloriesPerRep; }
uint16_t LiftingActivity::Sets() const { if (m_sets > 0) return m_sets; if (Total() > 0) return 1; return 0; }
std::vector<int> Lotto(int total,int choice) { std::vector<int> Total(total); for (int i=0; i<total; i++) { Total[i]=i+1; } random_shuffle(Total.begin(),Total.end()); return std::vector<int>(Total.begin(),Total.begin()+choice); }
time_t LiftingActivity::Pace() const { uint16_t total = Total(); if (total > 0) { return ElapsedTimeInSeconds() / total; } return 0; }
void cMyTextScroller::Scroll(bool Up, bool Page) { if (Up) { if (CanScrollUp()) { offset -= Page ? shown : 1; if (offset < 0) offset = 0; DrawText(); } } else { if (CanScrollDown()) { offset += Page ? shown : 1; if (offset + shown > Total()) offset = Total() - shown; DrawText(); } } }
void print(long double endtime, long double starttime, char *input, int *counter, int *countern, int *counterr, int *counterrf, int *numfile, int *nummerge) { int numsort,auxfile,numread,numwrite,numreg; long double exetime; exetime = ExecuteTime(endtime, starttime); numreg = NumberReg(input); numwrite = Total(counter, countern); numread = Total(counterr, counterrf); numsort = *nummerge; auxfile = *numfile; printf("\n"); printf("%.4Lf", endtime); printf("\n"); printf("%.4Lf", starttime); printf("\n"); printf("%d", *counter); printf("\n"); printf("%d", *countern); printf("\n"); printf("%d", *counterr); printf("\n"); printf("%d", *counterrf); printf("\n"); printf("%d", *numfile); printf("\n"); printf("%d", *nummerge); printf("\n"); printf("%.4Lf", exetime); printf("\n"); printf("%d", numreg); printf("\n"); printf("%d", numwrite); printf("\n"); printf("%d", numread); printf("\n"); return; }
void CreateReport(long double endtime,long double starttime, char *input, int *counter, int *countern, int *counterr, int *counterrf, int *numfile, int *nummerge) { int numreg, numwrite, numread, numsort, auxfile; double exetime; char string[]="exetime,numreg,numwrite,numread,numsort,numfile"; char aux[30]; FILE *report; exetime = ExecuteTime(endtime, starttime); numreg = NumberReg(input); numwrite = Total(counter, countern); numread = Total(counterr, counterrf); numsort = *nummerge; auxfile = *numfile; report = fopen("report","w"); sprintf(aux,"%f",exetime); fputs(string,report); fputs("\n",report); fputs(aux,report); fputs(",",report); sprintf(aux,"%d",numreg); fputs(aux,report); fputs(",",report); sprintf(aux,"%d",numwrite); fputs(aux,report); fputs(",",report); sprintf(aux,"%d",numread); fputs(aux,report); fputs(",",report); sprintf(aux,"%d",numsort); fputs(aux,report); fputs(",",report); sprintf(aux,"%d",auxfile); fputs(aux,report); fclose(report); return; }
void cMyTextScroller::Set(cOsd *Osd, int Left, int Top, int Width, int Height, const char *Text, const cFont *Font, tColor ColorFg, tColor ColorBg) { osd = Osd; left = Left; top = Top; width = Width; height = Height; font = Font; colorFg = ColorFg; colorBg = ColorBg; offset = 0; textWrapper.Set(Text, Font, Width); shown = min(Total(), height / font->Height()); height = shown * font->Height(); /* sets height to the actually used height, which may be less than Height */ DrawText(); }
void handleUpdate(UpdateEventDetails* const details, Transform* const TheSphereTransform) { static Real32 _TotalTime(0.0f); _TotalTime += details->getElapsedTime(); Matrix Translate; Translate.setTranslate(0.0,0.0,-5.0); Matrix Rotation; Rotation.setRotate(Quaternion(Vec3f(0.0,1.0,0.0), osgDegree2Rad(_TotalTime*80.0))); Matrix Total(Rotation); Total.mult(Translate); TheSphereTransform->setMatrix(Total); }
bool LiftingActivity::CheckRepsInterval() { if ((m_intervalWorkout.workoutId == INTERVAL_WORKOUT_ID_NOT_SET) || (m_intervalWorkoutState.nextSegmentIndex >= m_intervalWorkout.segments.size())) { return false; } const IntervalWorkoutSegment& segment = m_intervalWorkout.segments.at(m_intervalWorkoutState.nextSegmentIndex); if (segment.units == INTERVAL_UNIT_REPS) { uint16_t total = Total(); if (total >= segment.quantity) { return true; } } return false; }
void MyDayInfoPlot::DrawPricePlot(wxDC&dc){ TotalDayInfoStru MyDays[TOTAY_DAYS_MYDAYINFO]; double MaxSz,MinSz,MaxSh,MinSh,MaxTotal,MinTotal,MaxDelta,MinDelta; MaxSz=MinSz=MaxSh=MinSh=MaxTotal=MinTotal=MaxDelta=MinDelta=0; for (int tidx=0;tidx<TOTAY_DAYS_MYDAYINFO;tidx++){ MyDays[tidx].Valid=false; } wxString keyPath=WStockConfig::GetMyDayInfoPath(); wxFileName keyf(keyPath); keyf.MakeAbsolute(); xmlDocPtr doc=NULL; if (keyf.FileExists()){ //Load Stocks Name From file doc = xmlParseFile((const char*)keyf.GetFullPath().mb_str()); } //If Load Fail, Create the Xml Memory if (doc==NULL){ dc.DrawText(_("No Info File Found!"),10,10); return; } for (xmlNodePtr node=doc->children->children;node;node=node->next){ if (xmlStrcmp(node->name,(const xmlChar*)"DayInfo")==0){ wxString Date(wxConvUTF8.cMB2WC( (char*)xmlGetProp(node, (const xmlChar*)"Date")),*wxConvCurrent); wxString Sz(wxConvUTF8.cMB2WC( (char*)xmlGetProp(node, (const xmlChar*)"ShenZhen")),*wxConvCurrent); wxString Sh(wxConvUTF8.cMB2WC( (char*)xmlGetProp(node, (const xmlChar*)"ShangHai")),*wxConvCurrent); wxString Total(wxConvUTF8.cMB2WC( (char*)xmlGetProp(node, (const xmlChar*)"Total")),*wxConvCurrent); wxString Delta(wxConvUTF8.cMB2WC( (char*)xmlGetProp(node, (const xmlChar*)"TodayEarning")),*wxConvCurrent); wxDateTime date; date.ParseDate(Date); int idx=(wxDateTime::Today()-date).GetDays(); if (idx<TOTAY_DAYS_MYDAYINFO){ Sz.ToDouble(&MyDays[idx].sz); Sh.ToDouble(&MyDays[idx].sh); Total.ToDouble(&MyDays[idx].total); Delta.ToDouble(&MyDays[idx].delta); MyDays[idx].Valid = true; MyDays[idx].date = date; } } } int i; for (i=0;i<TOTAY_DAYS_MYDAYINFO;i++){ if (MyDays[i].Valid){ if (MyDays[i].sz>MaxSz) MaxSz = MyDays[i].sz; if (MyDays[i].sz<MinSz) MinSz = MyDays[i].sz; if (MyDays[i].sh>MaxSh) MaxSh = MyDays[i].sh; if (MyDays[i].sh<MinSh) MinSh = MyDays[i].sh; if (MyDays[i].total>MaxTotal) MaxTotal = MyDays[i].total; if (MyDays[i].total<MinTotal) MinTotal = MyDays[i].total; if (MyDays[i].delta>MaxDelta) MaxDelta = MyDays[i].delta; if (MyDays[i].delta<MinDelta) MinDelta = MyDays[i].delta; } } dc.SetPen(wxPen(*wxBLACK,3)); int XStart=100,YStart=10,YFree=60; int TotalY=dc.GetSize().y-30-YFree; int XTotal = dc.GetSize().x-110; float TotalDelta=0; if (MinDelta<0) TotalDelta = MaxTotal - MinDelta+YFree; else TotalDelta = MaxTotal+YFree; if (TotalDelta<0.0003) TotalDelta = 1; int ZeroY = (int)(double)(TotalY/TotalDelta * MaxTotal + YStart); dc.DrawLine(XStart,YStart,XStart,YStart + TotalY + YFree); dc.DrawLine(XStart-10,ZeroY,XStart+XTotal,ZeroY); for (i=0;i<TOTAY_DAYS_MYDAYINFO;i++){ if (MyDays[i].Valid){ int MyTotalY=(int)(double)(ZeroY - TotalY/TotalDelta * MyDays[i].total); int MyDeltaY=(int)(double)(ZeroY - TotalY/TotalDelta * MyDays[i].delta); dc.SetBrush(*wxBLACK_BRUSH); dc.DrawRectangle(XStart+(i+1)*(XTotal / (TOTAY_DAYS_MYDAYINFO + 1)) - 5,MyTotalY,10,Abs(ZeroY-MyTotalY)); dc.SetBrush(*wxGREEN_BRUSH); dc.DrawRectangle(XStart+(i+1)*(XTotal / (TOTAY_DAYS_MYDAYINFO + 1)) - 5,MyDeltaY,10,Abs(ZeroY-MyDeltaY)); //wxLogMessage(wxT("Draw Rect at:%d %d %d %d"),(int)(XStart+(i+1)*(XTotal / (TOTAY_DAYS_MYDAYINFO + 1)) - 5), //MyDeltaY,10,Abs(ZeroY-MyDeltaY)); dc.DrawText(MyDays[i].date.FormatISODate(),XStart+(i+1)*(XTotal / (TOTAY_DAYS_MYDAYINFO + 1))-30,YStart+TotalY); } } }
double PerlinNoise::GetHeight( const double &x, const double &y ) const { return m_dAmplitude * Total( x, y ); }
// Initialize WIN32 & OpenSG and set up the scene int main(int argc, char **argv) { // OSG init osgInit(argc,argv); { // Set up Window WindowEventProducerRecPtr TutorialWindow = createNativeWindow(); TutorialWindow->initWindow(); // Create the SimpleSceneManager helper SimpleSceneManager sceneManager; TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager)); TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager)); // Tell the Manager what to manage sceneManager.setWindow(TutorialWindow); //Attach to events TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1, &sceneManager)); TutorialWindow->connectMouseReleased(boost::bind(mouseReleased, _1, &sceneManager)); TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager)); TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager)); //Sound Emitter Node SoundEmitterRecPtr TheEmitter = SoundEmitter::create(); TheEmitter->attachUpdateProducer(TutorialWindow); NodeUnrecPtr TheEmitterNode = Node::create(); TheEmitterNode->setCore(TheEmitter); //Sphere Transformation Node Matrix Translate; Translate.setTranslate(0.0,0.0,-5.0); Matrix Rotation; Rotation.setRotate(Quaternion(Vec3f(0.0,1.0,0.0), 0.0)); Matrix Total(Translate); Total.mult(Rotation); TransformRecPtr TheSphereTransform = Transform::create(); TheSphereTransform->setMatrix(Total); NodeUnrecPtr SphereTransformNode = Node::create(); SphereTransformNode->setCore(TheSphereTransform); SphereTransformNode->addChild(makeSphere(2, 1.0)); SphereTransformNode->addChild(TheEmitterNode); // create the scene NodeUnrecPtr scene = Node::create(); scene->setCore(Group::create()); scene->addChild(SphereTransformNode); // tell the manager what to manage sceneManager.setRoot (scene); CameraUnrecPtr TheCamera = sceneManager.getCamera(); TheCamera->setNear(0.1); TheCamera->setFar(100.0); //Initialize the Sound Manager SoundManager::the()->attachUpdateProducer(TutorialWindow); SoundManager::the()->setCamera(sceneManager.getCamera()); SoundRecPtr PopSound = SoundManager::the()->createSound(); PopSound->setFile(BoostPath("./Data/pop.wav")); PopSound->setVolume(1.0); PopSound->setStreaming(false); PopSound->setLooping(-1); PopSound->setEnable3D(true); PopSound->connectSoundPlayed (boost::bind(handleSoundPlayed, _1)); PopSound->connectSoundStopped (boost::bind(handleSoundStopped, _1)); PopSound->connectSoundPaused (boost::bind(handleSoundPaused, _1)); PopSound->connectSoundUnpaused(boost::bind(handleSoundUnpaused, _1)); PopSound->connectSoundLooped (boost::bind(handleSoundLooped, _1)); //Attach this sound to the emitter node TheEmitter->setSound(PopSound); TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1, TheEmitter.get())); TutorialWindow->connectUpdate(boost::bind(handleUpdate, _1, TheSphereTransform.get())); //Create the Documentation SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow); Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f); Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5); TutorialWindow->openWindow(WinPos, WinSize, "02 Sound3D Window"); //Enter main loop TutorialWindow->mainLoop(); } osgExit(); return 0; }
ActivityAttributeType LiftingActivity::QueryActivityAttribute(const std::string& attributeName) const { ActivityAttributeType result; result.startTime = 0; result.endTime = 0; result.unitSystem = UnitMgr::GetUnitSystem(); if (attributeName.compare(ACTIVITY_ATTRIBUTE_REPS) == 0) { result.value.intVal = Total(); result.valueType = TYPE_INTEGER; result.measureType = MEASURE_COUNT; result.valid = result.value.intVal > 0; } else if (attributeName.compare(ACTIVITY_ATTRIBUTE_REPS_COMPUTED) == 0) { result.value.intVal = ComputedTotal(); result.valueType = TYPE_INTEGER; result.measureType = MEASURE_COUNT; result.valid = result.value.intVal > 0; } else if (attributeName.compare(ACTIVITY_ATTRIBUTE_REPS_CORRECTED) == 0) { result.value.intVal = CorrectedTotal(); result.valueType = TYPE_INTEGER; result.measureType = MEASURE_COUNT; result.valid = result.value.intVal > 0; } else if (attributeName.compare(ACTIVITY_ATTRIBUTE_CURRENT_PACE) == 0) { uint16_t total = Total(); result.value.timeVal = Pace(); result.valueType = TYPE_TIME; result.measureType = MEASURE_TIME; result.valid = total > 0; } else if (attributeName.compare(ACTIVITY_ATTRIBUTE_SETS) == 0) { uint16_t total = Total(); result.value.intVal = Sets(); result.valueType = TYPE_INTEGER; result.measureType = MEASURE_COUNT; result.valid = total > 0; } else if (attributeName.find(ACTIVITY_ATTRIBUTE_GRAPH_PEAK) == 0) { if (m_analyzer) { const char* numStr = attributeName.c_str() + strlen(ACTIVITY_ATTRIBUTE_GRAPH_PEAK); uint16_t num = atol(numStr); if ((num > 0) && (num <= m_computedRepList.size())) { GraphPeak peak = m_computedRepList.at(num - 1); result.valueType = TYPE_INTEGER; result.measureType = MEASURE_INDEX; result.value.intVal = peak.peak.index; result.valid = true; } else { result.valid = false; } } else { result.valid = false; } } else if (attributeName.find(ACTIVITY_ATTRIBUTE_MEAN_PEAK_AREA) == 0) { uint16_t total = Total(); result.value.doubleVal = GetPeakAreaMean(); result.valueType = TYPE_DOUBLE; result.measureType = MEASURE_NOT_SET; result.valid = total > 0; } else if (attributeName.find(ACTIVITY_ATTRIBUTE_STDDEV_PEAK_AREA) == 0) { uint16_t total = Total(); result.value.doubleVal = GetPeakAreaStdDev(); result.valueType = TYPE_DOUBLE; result.measureType = MEASURE_NOT_SET; result.valid = total > 0; } else { result = Activity::QueryActivityAttribute(attributeName); } return result; }
// |----------------------------------------------------------------------------| // | GetHeight | // |----------------------------------------------------------------------------| double PerlinNoise::GetHeight(double x, double y) const { return amplitude * Total(x, y); }
int main(int argc, char *argv[]) { int i, s; list q; list1 q1; list2 q2; record d; personal f; record *ptr, *pt; personal *ptr2, *pt2; FILE *fp, *fp1, *fp2, *fp3, *fp4, *fp6, *fp8, *fp9, *fp10; fp1 = fopen("b.txt", "a+"); node2 *st2; init(&q); init1(&q1); init2(&q2); char a[48]; char br[32]; int m, posi, choice, roll, size, s1, s2, s3, s4, num, posii, yr, MIS; while(1) { choice = printmenu(); switch(choice) { case 1 : printf("\nEnter the Name, MIS, Branch, Year of student and the MIS before which you wish to insert the record :\n"); /*if it is the first record 'posi' can be anything*/ scanf(" %[^\n]%d%s%d%d", a, &m, br, &yr, &posi); fp = fopen("k.txt", "a+"); Add_academic(&q, a, m, br, posi, yr, fp); fclose(fp); print(&q); break; case 2 : printf("Enter the MIS of the student record to be deleted :\n"); scanf("%d", &posii); fp = fopen("k.txt", "a+"); fp4 = fopen("d.txt", "w+"); if(pt = delet_academic(&q, posii,fp,fp4)) { printf("Name:%s\n MIS:%d\n Branch:%s\n Year :%d\n", pt->name, pt->MIS, pt->branch, pt->year); } else { printf("INVALID ENTRY\n"); } print(&q); fclose(fp); fclose(fp4); break; case 3 : printf("Enter the MIS of student :\n"); scanf("%d", &roll); if(ptr = search(&q, roll)) { printf("\nName :%s\tMIS :%d\tBranch :%s\tYear :%d\n", ptr->name, ptr->MIS, ptr->branch, ptr->year); } else { printf("\nRECORD NOT FOUND\n"); } break; case 4 : printf("Enter the Name, MIS, Branch, Year of student :\n"); scanf(" %[^\n]%d%s%d", a, &m, br, &yr); fp = fopen("k.txt", "a+"); append_academic(&q, a, m, br, yr, fp); print(&q); fclose(fp); break; case 5 : size = length(&q); printf("Number of student records(academic) : %d\n", size); break; case 6 : printf("Enter the MIS of student :\n"); scanf("%d", &roll); creatingID(&q, roll); break; case 7 : fp = fopen("k.txt", "a+"); fp3 = fopen("a.txt", "r"); academicfromfile(&q, fp3, fp); print(&q); fclose(fp); fclose(fp3); break; case 8 : printf("Enter the Name, MIS, Branch and Year of student:\n"); scanf(" %[^\n]%d%s%d", a, &m, br, &yr); /*MIS should be same*/ fp = fopen("k.txt", "a+"); fp6 = fopen("n.txt", "w+"); Modify_academic(&q, m, a, br, yr, fp, fp6); print(&q); fclose(fp); fclose(fp6); break; case 9 : num = length1(&q1); printf("No of students who appeared for final exam : %d\n", num); break; case 10 : printf("Enter MIS, T1 marks of 4 subjects ,MIS before which you wish to enter the record and the semester :\n"); scanf("%d%d%d%d%d%d%d",&roll,&s1,&s2,&s3,&s4,&m, &i); T1Marks(&q1,roll,s1,s2,s3,s4,m,i); printT1(&q1, i); break; case 11 : printf("Enter MIS and T2 marks of 4 subjects and the semester :\n"); scanf("%d%d%d%d%d%d",&roll,&s1,&s2,&s3,&s4, &i); T2Marks(&q1,roll,s1,s2,s3,s4,i); printT2(&q1, i); break; case 12 : printf("Enter MIS and ESE marks of 4 subjects and the semester :\n"); scanf("%d%d%d%d%d%d",&roll,&s1,&s2,&s3,&s4,&i); ESEMarks(&q1,roll,s1,s2,s3,s4,i); printESE(&q1, i); break; case 13 : printf("Enter the MIS and the semester :\n"); scanf("%d%d", &MIS, &i); Total(&q1, MIS,i, fp1); printTOT(&q1, i); break; case 14 : printf("Enter the Name, MIS, Mobile no., Email Id of student and the MIS before which you wish to insert the record :\n"); /*if it is the first record, posi can be anything*/ scanf(" %[^\n]%d%d%s%d", a, &m, &yr, br, &posi); fp2 = fopen("c.txt", "a+"); Add2_personal(&q2, a, m, yr, br, posi, fp2); print2(&q2); fclose(fp2); break; case 15 : printf("Enter the MIS of the student record to be deleted :\n"); scanf("%d", &posii); fp2 = fopen("c.txt", "a+"); fp9 = fopen("s.txt", "w+"); if(pt2 = delet2_personal(&q2, posii,fp2, fp9)) { printf("Name:%s\n MIS:%d\n Mobile No:%d\n Email Id :%s\n", pt2->name, pt2->MISS, pt2->mobile, pt2->email_Id); } else { printf("INVALID ENTRY\n"); } print2(&q2); fclose(fp2); fclose(fp9); break; case 16 : printf("Enter the MIS of student :\n"); scanf("%d", &roll); if(ptr2 = search2(&q2, roll)) { printf("\nName :%s\tMIS :%d\tMobile No :%d\tEmail Id :%s\n", ptr2->name, ptr2->MISS, ptr2->mobile, ptr2->email_Id); } else { printf("\nRECORD NOT FOUND\n"); } break; case 17 : printf("Enter the Name, MIS, Mobile no. and Email Id of student:\n"); scanf(" %[^\n]%d%d%s", a, &m, &yr, br); /*MIS should be same*/ fp8 = fopen("w.txt", "w+"); fp2 = fopen("c.txt", "a+"); Modify2_personal(&q2, m, a, yr, br,fp2, fp8); print2(&q2); fclose(fp2); fclose(fp8); break; case 18 : printf("\nEnter the MIS of the student and the semester :\n"); scanf("%d%d", &m, &s); link(&q, &q1, &q2, m, s); break; case 19 : fp2 = fopen("c.txt", "a+"); fp10 = fopen("p.txt", "r"); personalfromfile(&q2, fp10, fp2); print2(&q2); fclose(fp2); fclose(fp10); break; case 20 : fclose(fp1); exit(1); break; } } }