int main(int argc, char const *argv[]) { int n; printf("复制文件还是目录? 文件输入:1 目录输入:2\n"); scanf("%d",&n); if(n==1) { char filename1[128]; char filename2[128]; printf("请输入你想复制的文件名!\n"); scanf("%s",&filename1); printf("请输入你复制后的文件名!\n"); scanf("%s",&filename2); cp1(filename1,filename2); } else if(n==2) { char filename1[128]; char filename2[128]; printf("请输入你想复制的目录名!\n"); scanf("%s",&filename1); printf("请输入你复制后的目录名!\n"); scanf("%s",&filename2); cp3(filename2,1,0); cp2(filename1,filename2); } else { printf("输入有误 请重新运行后输入\n"); } return 0; }
void cp2(char filename1[],char filename2[]) { char path2[256]; char path1[256]; strcat(path2,filename2); strcat(path1,filename1); DIR* dir=opendir(filename1); chdir(filename1); if(dir!=NULL) { struct dirent *ent=NULL; struct stat buf; ent=readdir(dir); while(ent!=NULL) { if(strcmp(ent->d_name,".")!=0 && strcmp(ent->d_name,"..")!=0) { stat(ent->d_name,&buf); if(S_ISDIR(buf.st_mode)) { chdir(path2); cp3(ent->d_name,1,0); strcat(path2,"/"); strcat(path2,ent->d_name); chdir(path1); strcat(path1,"/"); strcat(path1,ent->d_name); cp2(ent->d_name,NULL); } else { char c[1]; int fd=open(ent->d_name,O_RDWR); int ret=1; while(ret!=0) { ret=read(fd,c,sizeof(c)); chdir(path2); cp3(ent->d_name,2,c); } close(fd); } } ent=readdir(dir); } chdir(".."); cp3("..",1,0); } }
// Construct a Line NURBS by changing space dimension and ordering of //coordinates. MGRSBRep::MGRSBRep( size_t dim, // New space dimension. const MGRSBRep& rsb,// Original Surface B-rep. size_t start1, // Destination order of new line. size_t start2) // Source order of original line. :MGSurface(rsb){ update_mark(); size_t dim0=rsb.sdim(); MGSPointSeq cp1(dim0,rsb.surface_bcoef());//Exclude weights. MGSPointSeq cp2(dim,cp1,start1,start2); //Change order of coordinates. MGSPointSeq cp3(dim+1,cp2); //Get area for weights. for(size_t i=0; i<cp3.length_u(); i++) for(size_t j=0; j<cp3.length_v(); j++) cp3(i,j,dim)=rsb.surface_bcoef()(i,j,dim0);//Set weights. m_surface=MGSBRep(cp3,rsb.knot_vector_u(),rsb.knot_vector_v()); }
//Changing this object's space dimension. MGRSBRep& MGRSBRep::change_dimension( size_t dim, // new space dimension size_t start1, // Destination order of new object. size_t start2) // Source order of this object. { size_t dim0=sdim(); MGSPointSeq cp1(dim0,surface_bcoef()); //Exclude weights. MGSPointSeq cp2(dim,cp1,start1,start2); //Change order of coordinates. MGSPointSeq cp3(dim+1,cp2); //Get area for weights. const MGSPointSeq& sp=surface_bcoef(); for(size_t i=0; i<cp3.length_u(); i++) for(size_t j=0; j<cp3.length_v(); j++) cp3(i,j,dim)=sp(i,j,dim0);//Set weights. m_surface=MGSBRep(cp3,knot_vector_u(),knot_vector_v()); update_mark(); return *this; }
// Check the state. It should always be valid. void MyInfo::checkState(robot_interaction::LockedRobotState &locked_state) { robot_state::RobotStateConstPtr s = locked_state.getState(); robot_state::RobotState cp1(*s); // take some time cnt_lock_.lock(); cnt_lock_.unlock(); cnt_lock_.lock(); cnt_lock_.unlock(); cnt_lock_.lock(); cnt_lock_.unlock(); // check mim_f == joint_f EXPECT_EQ(s->getVariablePositions()[MIM_F], s->getVariablePositions()[JOINT_F] * 1.5 + 0.1); robot_state::RobotState cp2(*s); EXPECT_NE(cp1.getVariablePositions(), cp2.getVariablePositions()); EXPECT_NE(cp1.getVariablePositions(), s->getVariablePositions()); int cnt = cp1.getVariableCount(); for (int i = 0 ; i < cnt ; ++i) { EXPECT_EQ(cp1.getVariablePositions()[i], cp2.getVariablePositions()[i]); EXPECT_EQ(cp1.getVariablePositions()[i], s->getVariablePositions()[i]); } // check mim_f == joint_f EXPECT_EQ(s->getVariablePositions()[MIM_F], s->getVariablePositions()[JOINT_F] * 1.5 + 0.1); }
void Game::init() { #ifdef WIN32 device = createDevice(video::EDT_DIRECT3D9, core::dimension2d<s32>(640, 480)); #else device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480)); #endif driver = device->getVideoDriver(); smgr = device->getSceneManager(); guienv = device->getGUIEnvironment(); device->setWindowCaption(L"Not So Much Super Offroad - By Andreas Kröhnke"); IMeshSceneNode *node = smgr->addMeshSceneNode( smgr->getMesh("data/car3.3ds")->getMesh(0) ); GameObject *car = new GameObject(); car->setSceneNode(node); node->setMaterialFlag(EMF_LIGHTING, false); node->setScale(vector3df(0.09,0.09,0.09)); node->setRotation(vector3df(0,0,0)); node->setPosition(vector3df(3454,500,1256)); //node->setDebugDataVisible(EDS_BBOX); object->push_back(car); ITerrainSceneNode *terrain = smgr->addTerrainSceneNode("data/level1.bmp"); GameObject *go_terrain = new GameObject(); go_terrain->setSceneNode(terrain); terrain->setMaterialFlag(EMF_LIGHTING, false); terrain->setScale(core::vector3df(18, 3.0f, 18)); terrain->setMaterialFlag(video::EMF_LIGHTING, false); terrain->setMaterialTexture(0, driver->getTexture("data/terrain-texture.jpg")); terrain->setMaterialTexture(1, driver->getTexture("data/detailmap3.jpg")); terrain->setMaterialType(video::EMT_DETAIL_MAP); terrain->scaleTexture(1.0f, 20.0f); terrain->setDebugDataVisible(EDS_BBOX); object->push_back(go_terrain); // Camera Camera *cam = new Camera(); cam->setSceneNode(smgr->addCameraSceneNode()); object->push_back(cam); cam->followNode(car->getSceneNode()); reciever = new EventReciever(); reciever->setSteer(car->getSceneNode()); device->setEventReceiver(reciever); // create triangle selector for the terrain ITriangleSelector* selector = smgr->createTerrainTriangleSelector(terrain, 0); terrain->setTriangleSelector(selector); selector->drop(); // create collision response animator and attach it to the camera ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(selector, car->getSceneNode(), core::vector3df(10,10,10), core::vector3df(0,-5.0f,0), core::vector3df(0,0,0) ); car->getSceneNode()->addAnimator(anim); anim->drop(); // Skybox smgr->addSkyBoxSceneNode( driver->getTexture("data/irrlicht2_up.jpg"), driver->getTexture("data/irrlicht2_dn.jpg"), driver->getTexture("data/irrlicht2_lf.jpg"), driver->getTexture("data/irrlicht2_rt.jpg"), driver->getTexture("data/irrlicht2_ft.jpg"), driver->getTexture("data/irrlicht2_bk.jpg")); // Checkpoints pair<vector3df, vector3df> cp1(vector3df(3112,393,1234), vector3df(90,90,0)); addCheckPoint(cp1.first, cp1.second); pair<vector3df, vector3df> cp2(vector3df(2531,281,1389), vector3df(90,120,0)); addCheckPoint(cp2.first, cp2.second); addCheckPoint(vector3df(2304,160,1826), vector3df(90,140,0)); addCheckPoint(vector3df(2132,111,2672), vector3df(90,120,0)); addCheckPoint(vector3df(1130,415,3313), vector3df(90,75,0)); addCheckPoint(vector3df(746,471,1753), vector3df(90,0,0)); addCheckPoint(vector3df(1985,269,1457), vector3df(90,-120,0)); addCheckPoint(vector3df(2475,146,2868), vector3df(90,-120,0)); addCheckPoint(vector3df(3707,417,2915), vector3df(90,-60,0)); // Arrows addArrow(vector3df(3012,320,1234), vector3df(100,-55,0)); addArrow(vector3df(2531,220,1389), vector3df(100,-10,0)); //addArrow(vector3df(2304,110,1826), vector3df(90,10,0)); addArrow(vector3df(2232,20,2272), vector3df(90,-20,0)); // HUD info = guienv->addStaticText(L"USE ARROW KEYS TO PLAY", rect<int>(10,10,200,60), true); info->setOverrideColor(SColor(255, 255, 255, 255)); //IGUIStaticText *quick_info = guienv->addStaticText(L"Arrow keys to play\n", rect<int>(10,50,200,50), true); //quick_info->setOverrideColor(SColor(255,255,255,255)); initSound(); }
/*! Checks to see if the given AP is identical to itself ([this]). It also contains some useful points of instrumentation for benchmarking table and usage characteristics. \return TRUE, if and only if we match the AP given, false otherwise. */ bool PP_AttrProp::isExactMatch(const PP_AttrProp * pMatch) const { // The counters below are used in testing to profile call and chksum characteristics, // including collision rates. // NB: I'm not sure this initialization block is in the correct place. #ifdef PT_TEST static UT_uint32 s_Calls = 0; static UT_uint32 s_PassedCheckSum = 0; static UT_uint32 s_Matches = 0; #endif #ifdef PT_TEST s_Calls++; #endif UT_return_val_if_fail (pMatch, false); // // Why is this here? Nothing is being changed? // UT_return_val_if_fail (m_bIsReadOnly && pMatch->m_bIsReadOnly, false); if (m_checkSum != pMatch->m_checkSum) return false; #ifdef PT_TEST s_PassedCheckSum++; #endif UT_uint32 countMyAttrs = ((m_pAttributes) ? m_pAttributes->size() : 0); UT_uint32 countMatchAttrs = ((pMatch->m_pAttributes) ? pMatch->m_pAttributes->size() : 0); if (countMyAttrs != countMatchAttrs) return false; UT_uint32 countMyProps = ((m_pProperties) ? m_pProperties->size() : 0); UT_uint32 countMatchProps = ((pMatch->m_pProperties) ? pMatch->m_pProperties->size() : 0); if (countMyProps != countMatchProps) return false; if (countMyAttrs != 0) { UT_GenericStringMap<gchar*>::UT_Cursor ca1(m_pAttributes); UT_GenericStringMap<gchar*>::UT_Cursor ca2(pMatch->m_pAttributes); const gchar * v1 = ca1.first(); const gchar * v2 = ca2.first(); do { const gchar *l1 = ca1.key().c_str(); const gchar *l2 = ca2.key().c_str(); if (strcmp(l1, l2) != 0) return false; l1 = v1; l2 = v2; if (strcmp(l1,l2) != 0) return false; v1 = ca1.next(); v2 = ca2.next(); } while (ca1.is_valid() && ca2.is_valid()); } if (countMyProps > 0) { UT_GenericStringMap<PropertyPair*>::UT_Cursor cp1(m_pProperties); UT_GenericStringMap<PropertyPair*>::UT_Cursor cp2(pMatch->m_pProperties); const PropertyPair* v1 = cp1.first(); const PropertyPair* v2 = cp2.first(); do { const gchar *l1 = cp1.key().c_str(); const gchar *l2 = cp2.key().c_str(); if (strcmp(l1, l2) != 0) return false; l1 = v1->first; l2 = v2->first; if (strcmp(l1,l2) != 0) return false; v1 = cp1.next(); v2 = cp2.next(); } while (cp1.is_valid() && cp2.is_valid()); #ifdef PT_TEST s_Matches++; #endif } return true; }
void CCue::PaintPointer(CPaintDC* dc, int l) { COLORREF blue = RGB(0, 103, 223); CFlowZap *fc = ((CFlowZap*)m_Parent); try { CPen *oldPen; CBrush *oldBrush; CPen cp; CBrush cb; // if the user is dragging : red if (m_dragging) { cp.CreatePen(PS_SOLID, 1, COLORREF(0x0000ff)); oldPen = dc->SelectObject(&cp); cb.CreateSolidBrush(COLORREF(0x0000ff)); oldBrush = dc->SelectObject(&cb); } // if the user is running a program: green else if (fc->m_ProgramMode == pmExecute) { cp.CreatePen(PS_SOLID, 1, COLORREF(0x00ff00)); oldPen = dc->SelectObject(&cp); cb.CreateSolidBrush(COLORREF(0x00ff00)); oldBrush = dc->SelectObject(&cb); } // otherwise blue else { cp.CreatePen(PS_SOLID, 1, blue); oldPen = dc->SelectObject(&cp); cb.CreateSolidBrush(blue); oldBrush = dc->SelectObject(&cb); } vertices[0].x = 7; vertices[0].y = l - 5; vertices[1].x = 7; vertices[1].y = l + 5; vertices[2].x = 17; vertices[2].y = l + 5; vertices[3].x = 23; vertices[3].y = l; vertices[4].x = 17; vertices[4].y = l - 5; dc->Polygon(vertices, 5); CPen cp2(PS_SOLID, 1, COLORREF(0xffffff)); dc->SelectObject(&cp2); dc->MoveTo(7, l - 4); dc->LineTo(17, l - 4); dc->LineTo(22, l - 1); CPen cp3(PS_SOLID, 1, COLORREF(0x000000)); dc->SelectObject(&cp3); dc->MoveTo(7, l + 4); dc->LineTo(17, l + 4); dc->LineTo(22, l + 1); dc->SelectObject(oldPen); dc->SelectObject(oldBrush); cp.DeleteObject(); cb.DeleteObject(); cp2.DeleteObject(); cp3.DeleteObject(); } catch (CResourceException e) { int i = 0; } }
void printtime(tm *cl){ system("cls"); COORD pos; HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); pos.X = 33; pos.Y = 9; SetConsoleCursorPosition(hConsole, pos); printf("%d:%d:%d", cl->tm_hour, cl->tm_min, cl->tm_sec); int arrH[8] = {0}; int arrM[8] = {0}; int arrS[8] = {0}; int a1, a2, a3, b1, b2, b3; a1 = cl->tm_hour % 10; b1 = cl->tm_hour / 10; a2 = cl->tm_min % 10; b2 = cl->tm_min / 10; a3 = cl->tm_sec % 10; b3 = cl->tm_sec / 10; for(int i = 0; i < 4; i++){ if(cp2(a1, i)) arrH[7 - i] = 1; if(cp2(b1, i)) arrH[3 - i] = 1; if(cp2(a2, i)) arrM[7 - i] = 1; if(cp2(b2, i)) arrM[3 - i] = 1; if(cp2(a3, i)) arrS[7 - i] = 1; if(cp2(b3, i)) arrS[3 - i] = 1; } if(cp2) for(int i = 0; i < 8; i++){ pos.Y = 12 + i % 4; pos.X = 32 + i / 4; SetConsoleCursorPosition(hConsole, pos); if(arrH[i]) SetConsoleTextAttribute(hConsole, 0xff); else SetConsoleTextAttribute(hConsole, 0x0f); printf(" "); pos.Y = 12 + i % 4; pos.X = 35 + i / 4; SetConsoleCursorPosition(hConsole, pos); if(arrM[i]) SetConsoleTextAttribute(hConsole, 0xff); else SetConsoleTextAttribute(hConsole, 0x0f); printf(" "); pos.Y = 12 + i % 4; pos.X = 38 + i / 4; SetConsoleCursorPosition(hConsole, pos); if(arrS[i]) SetConsoleTextAttribute(hConsole, 0xff); else SetConsoleTextAttribute(hConsole, 0x0f); printf(" "); SetConsoleTextAttribute(hConsole, 0x0f); } }
virtual void draw(GiGraphics& gs, const Matrix2d& w2d) const { Point2d cp2(cp * w2d), pt2(pt * w2d); gs.getCanvas()->quadTo(cp2.x, cp2.y, pt2.x, pt2.y); }