node* convert2(node *root){ if(root==NULL)return NULL; if(root->left!=NULL){ node left = convert2(root->left); while(;left->right!=NULL;left=left->right); left->right=root; root->left=left; }
char * Num_To_HexVar_32(uint32_t TOHVINPUT) //UINT32 TO HEXIFIED VAR { //Code to varint - py static char convert_result2[3]="\0"; bzero(convert_result2,3); convert_result2[2] = '\0'; memset(convert_result2,0,sizeof(convert_result2)); uint8_t buf[1] = {0}; bzero(buf,1); uvarint_encode32(TOHVINPUT, buf, 1); convert2(convert_result2,buf); return convert_result2; }
int main() { check1(); check2(); convert1(); convert2(); convert3(); convert4(); convert5(); return 0; }
void QPolyTime::parse2(QString& filePath) { if(filePath.isEmpty() == true) { return ; } QFile file(filePath); if(file.open(QIODevice::ReadOnly) == false) { return ; } QTextStream stream(&file); stream.setCodec("UTF-8"); QStringList list; while(stream.atEnd() == false) { QString line1 = stream.readLine().trimmed(); list.append(convert2(line1)); //qDebug()<<convert(line); } file.close(); QString newfilePath = filePath; newfilePath.replace("timeTable", "tracePoints"); newfilePath.replace(".txt", ".lua"); QFile file2(newfilePath); if(file2.open(QIODevice::WriteOnly) == false) { qDebug()<<"open failed"; return ; } QString str; str += QString("function %1.elapse(cityID1, cityID2)\n").arg(m_name); str += QString(" local funName = \"elapse_\" .. tostring(cityID1) .. \"_\" .. tostring(cityID2)\n "); str += QString(" if cityID1 > cityID2 then\n"); str += QString(" funName = \"elapse_\" .. tostring(cityID2) .. \"_\" .. tostring(cityID1)\n "); str += QString(" end\n"); str += QString(" if %1[funName] == nil then\n").arg(m_name); str += QString(" return nil\n"); str += QString(" end\n"); str += QString(" return %1[funName]();\n").arg(m_name); str += QString("end\n\n"); QTextStream stream2(&file2); stream2.setCodec("UTF-8"); stream2<<QString("local %1 = {}\n").arg(m_name); foreach(QString single, list) { stream2<<single<<"\n"; } stream2<<str<<"\n"; stream2<<QString("return %1").arg(m_name); file2.close(); qDebug()<<"ok"; }
void Jeu::ChargerUnite() { //Creation des textures: //Chargement des textures de la barre de vie et de selections SDL_Surface *barreVieSurface=IMG_Load("Jeu/Images/barre_vie.png"); SDL_Surface *vieSurface=IMG_Load("Jeu/Images/vie.png"); SDL_Surface *selectionSurface=IMG_Load("Jeu/Images/selection_unite.png"); SDL_Surface *selectionSurfaceEnnemie=IMG_Load("Jeu/Images/selection_unite_ennemie.png"); RenderableObject::BarreVieTexture = SDL_CreateTextureFromSurface(renderer,barreVieSurface); RenderableObject::VieTexture = SDL_CreateTextureFromSurface(renderer,vieSurface); RenderableObject::SelectionUniteTexture = SDL_CreateTextureFromSurface(renderer,selectionSurface); RenderableObject::SelectionUniteEnnemieTexture = SDL_CreateTextureFromSurface(renderer,selectionSurfaceEnnemie); SDL_FreeSurface(selectionSurfaceEnnemie); SDL_FreeSurface(selectionSurface); SDL_FreeSurface(barreVieSurface); SDL_FreeSurface(vieSurface); std::string nomFichier; if(taille==1) { nomFichier="Save/unite1.lvl"; } else { nomFichier="Save/unite2.lvl"; } std::ifstream fichier(nomFichier.c_str(), std::ios::in); std::string mot; while(fichier >> mot && mot[0] !='-') { char type=mot[0]; SDL_Rect positionUnitSurCarte; positionUnitSurCarte.h=humainCaCTextures->positionTexture[0][0].h; positionUnitSurCarte.w=humainCaCTextures->positionTexture[0][0].w; fichier >> mot; int result; std::stringstream convert(mot); convert >> result; positionUnitSurCarte.x=result; //Remplissage de la composante y de la texture fichier>>mot; std::stringstream convert2(mot); convert2 >> result; positionUnitSurCarte.y=result; if(type=='d') { UnitDistance *unite=new UnitDistance(type,true,positionUnitSurCarte,renderer,maCarte->cartePassage,*humainDistanceTextures,objects,1); uniteJoueur.push_back(unite); objects.push_back(unite); } else if(type=='c') { UnitCaC *unite= new UnitCaC(type,true,positionUnitSurCarte,renderer,maCarte->cartePassage,*humainCaCTextures,objects,1); uniteJoueur.push_back(unite); objects.push_back(unite); } } while(fichier >> mot) { char type=mot[0]; SDL_Rect positionUnitSurCarte; positionUnitSurCarte.h=orcCaCTextures->positionTexture[0][0].h; positionUnitSurCarte.w=orcCaCTextures->positionTexture[0][0].w; fichier >> mot; int result; std::stringstream convert(mot); convert >> result; positionUnitSurCarte.x=result; //Remplissage de la composante y de la texture fichier>>mot; std::stringstream convert2(mot); convert2 >> result; positionUnitSurCarte.y=result; if(type=='c') { std::vector<Task*>* tasks = new std::vector<Task*>(); Explore* explore = new Explore("explore"); Attack* attack = new Attack("attack"); tasks->push_back(explore); tasks->push_back(attack); AIController* contro = new AIController(*tasks); UnitCaC *unite =new UnitCaC(type,false,positionUnitSurCarte,renderer,maCarte->cartePassage,contro,*orcCaCTextures,objects,2); uniteOrdinateur.push_back(unite); objects.push_back(unite); } else if(type=='d') { std::vector<Task*>* tasks = new std::vector<Task*>(); Explore* explore = new Explore("explore"); Attack* attack = new Attack("attack"); tasks->push_back(explore); tasks->push_back(attack); AIController* contro = new AIController(*tasks); UnitDistance *unite = new UnitDistance(type,false,positionUnitSurCarte,renderer,maCarte->cartePassage,contro,*orcDistanceTextures,objects,2); uniteOrdinateur.push_back(unite); objects.push_back(unite); } } fichier.close(); }
wxSize SlideShow::ToGif(wxString file) { wxArrayString which; bool success = true; wxString convert(wxT("convert -delay "+wxString::Format(wxT("%i"),100/GetFrameRate()))); // At least one ImageMagick version for windows comes without that symlink // See https://github.com/andrejv/wxmaxima/issues/757 wxString convert2(wxT("magick -delay "+wxString::Format(wxT("%i"),100/GetFrameRate()))); wxString convertArgs; wxString tmpdir = wxFileName::GetTempDir(); for (int i=0; i<m_size; i++) { wxFileName imgname(tmpdir, wxString::Format(wxT("wxm_anim%d.png"), i)); wxImage image = m_images[i]->ToImageFile(imgname.GetFullPath()); convert << wxT(" \"") << imgname.GetFullPath() << wxT("\""); } convert << wxT(" \"") << file << wxT("\""); #if defined __WXMSW__ if (!wxShell(convert)) if (!wxShell(convert2)) #else if (wxExecute(convert, wxEXEC_SYNC) != 0) if (wxExecute(convert2, wxEXEC_SYNC) != 0) #endif { success = false; wxMessageBox(_("There was an error during GIF export!\n\nMake sure ImageMagick is installed and wxMaxima can find the convert program."), wxT("Error"), wxICON_ERROR); } for (int i=0; i<m_size; i++) { wxFileName imgname(tmpdir, wxString::Format(wxT("wxm_anim%d.png"), i)); wxRemoveFile(imgname.GetFullPath()); } if(success) { if(m_size>0) return wxSize(m_images[1]->GetOriginalWidth(),m_images[1]->GetOriginalHeight()); else { wxSize retval; retval.x=retval.y=0; return retval; } } else { wxSize retval; retval.x=retval.y=-1; return retval; } }
void mainmenu(){ /// have to change the color (sajid) //puts("MainMenu"); glBegin( GL_POINTS ); glColor3f(1,0,0); for(int i=0;i<=100;i++){ for(int j=0;j<=100;j++){ // glVertex2d( i,j); } } glEnd(); glColor3f(0,0,0); glPushMatrix(); glLoadIdentity(); glTranslatef(-350,-280,0); //texture maping of left field int r,c,r1; double p1,c1; for(r=0;r<menu5.width;r++) { for(c=0;c<menu5.height;c++) { glBegin(GL_POINTS); float rr=(float)(menu5.pixel(r,c,0)); float gg=(float)(menu5.pixel(r,c,1)); float bb=(float)(menu5.pixel(r,c,2)); if(print_flag && c<30) printf("%3.0f,%3.0f,%3.0f, ",rr,gg,bb); glColor3f(rr/255,gg/255.0,bb/255.0); glVertex2d(r,c); glEnd(); } if(print_flag) puts(""); } if(print_flag) printf("%d %d\n",r,c); print_flag=0; glPopMatrix(); glPushMatrix(); glLoadIdentity(); glTranslatef(-300,0,0); for(r=0;r<menu5.width;r++) { for(c=0;c<menu5.height;c++) { glBegin(GL_POINTS); float rr=(float)(menu5.pixel(r,c,0)); float gg=(float)(menu5.pixel(r,c,1)); float bb=(float)(menu5.pixel(r,c,2)); convert2(rr); convert2(gg); convert2(bb); glColor3f(rr/255,gg/255.0,bb/255.0); glVertex2d(r,c); glEnd(); } if(!print_flag)puts(""); } glPopMatrix(); }
int main() { printf("Start...."); start: printf("\n(input) "); //계산기 프로그램 시작 scanf("%s", in1); str_in1 = strlen(in1); c_hoice(); if (chosen != 1){ scanf("%s", in2); str_in2 = strlen(in2); scanf("%s", in3); str_in3 = strlen(in3); check_sign_in1(); check_sign_in3(); re_array_in1(); re_array_in3(); separate(); if(in2[0] == '-'){ if(minus_sign_count == 0) in2[0] = '-'; else if(minus_sign_count == 1){ if(if_minus_first == 1){ in2[0] = '+'; when_put_minus =1;} if(if_minus_last == 1) in2[0] = '+';} else{ in2[0] = '-'; when_remove_minus =1;}} else if(in2[0] == '+'){ if(minus_sign_count == 0) in2[0] = '+'; else if(minus_sign_count == 1){ if(if_minus_first == 1) in2[0] = '-'; if(if_minus_last == 1) in2[0] = '-';} else{ in2[0] = '+'; when_put_minus=1;}} else if(in2[0] == '*'){ if(minus_sign_count == 0 || minus_sign_count == 2) in2[0] = '*'; else if(minus_sign_count == 1){ in2[0] = '*'; when_put_minus=1;}} else if(in2[0] == '/'){ if(minus_sign_count == 0 || minus_sign_count == 2) in2[0] = '/'; else if(minus_sign_count == 1){ in2[0] = '/'; when_put_minus=1;}} else if(in2[0] == '%'){ if(minus_sign_count == 0 || minus_sign_count == 2) in2[0] = '%'; else if(minus_sign_count == 1){ in2[0] = '%'; when_put_minus=1;}} switch (in2[0]) { case '+' : { invert1(); convert1(); plus(); convert2(); invert2(); break; } case '-' : { invert1(); compare(); convert1(); minus(); convert2(); invert2(); break; } case '*' : { invert1(); invert1_mul_s(); multiply(); invert2(); invert2_mul_s(); break; } case '/' : { invert1(); compare(); convert1(); divide(); convert2(); invert2(); break; } case '%' : { invert1(); compare(); convert1(); remain(); convert2(); invert2(); break; } default: ; } printf(" = "); if(when_put_minus == 1) printf("-"); // if(when_remove_minus == 1) //여기서 - 부호 하나를 배열에서 빼주는 명령어 쓸 수 없을까? if (daeso == 1) printf("-"); comma(res_j); if (p != 0) {printf("."); comma(res_s);} } initialization(); goto start; return 0; }
int main() { printf("Start...."); start: printf("\n(input) "); //계산기 프로그램 시작 input(); error(); if(again == 1) { initialization(); goto start; } c_hoice(); if (chosen != 1){ //in1에 입력받은 문자가 1자리 대소문자가 아닌 경우 var_cal(); if (var_cal_switch == 1) { printf(" = error\n"); initialization(); goto start; } check_sign_in1(); // input1 +/- 부호 체크 check_sign_in3(); // input3 +/- 부호 체크 re_array_in1(); // 다항 연산 고려 순서 바꿔 저장 re_array_in3(); // 다항 연산 고려 순사 바꿔 저장 separate(); which_sign(); switch (in2[0]) { case '+' : { invert1(); convert1(); plus(); convert2(); invert2(); break; } case '-' : { invert1(); compare(); convert1(); minus(); convert2(); invert2(); break; } case '*' : { invert1(); invert1_mul_s(); multiply(); invert2(); invert2_mul_s(); break; } case '/' : { dividing(); break; } case '%' : { remain2(); break; } default: ; } printf(" = "); if(when_put_minus == 1) printf("-"); if (daeso == 1) printf("-"); comma(res_j); if (p != 0) {printf("."); comma(res_s);} } initialization(); goto start; return 0; }
void test() { __v16sc gv1; __v16uc gv2; __v8ss gv3; __v8us gv4; __v4si gv5; __v4ui gv6; __v2sll gv7; __v2ull gv8; __v1slll gv9; __v1ulll gv10; __v4f gv11; __v2d gv12; vector signed char av1; vector unsigned char av2; vector signed short av3; vector unsigned short av4; vector signed int av5; vector unsigned int av6; vector signed long long av7; vector unsigned long long av8; vector signed __int128 av9; vector unsigned __int128 av10; vector float av11; vector double av12; vector bool int av13; vector pixel short av14; __v16sc *gv1_p = convert1(gv1); __v16uc *gv2_p = convert1(gv2); __v8ss *gv3_p = convert1(gv3); __v8us *gv4_p = convert1(gv4); __v4si *gv5_p = convert1(gv5); __v4ui *gv6_p = convert1(gv6); __v2sll *gv7_p = convert1(gv7); __v2ull *gv8_p = convert1(gv8); __v1slll *gv9_p = convert1(gv9); __v1ulll *gv10_p = convert1(gv10); __v4f *gv11_p = convert1(gv11); __v2d *gv12_p = convert1(gv12); vector signed char *av1_p = convert2(av1); vector unsigned char *av2_p = convert2(av2); vector signed short *av3_p = convert2(av3); vector unsigned short *av4_p = convert2(av4); vector signed int *av5_p = convert2(av5); vector unsigned int *av6_p = convert2(av6); vector signed long long *av7_p = convert2(av7); vector unsigned long long *av8_p = convert2(av8); vector signed __int128 *av9_p = convert2(av9); vector unsigned __int128 *av10_p = convert2(av10); vector float *av11_p = convert2(av11); vector double *av12_p = convert2(av12); convert2(av13); // expected-error {{call to 'convert2' is ambiguous}} convert2(av14); // expected-error {{call to 'convert2' is ambiguous}} }
ALWAYS_INLINE void convert(fvec2 from, uvec2& to) { convert2(from, to); }
int main( int argc, char* const argv[] ) { static const char* clopt = "i:o:dtr"; char srcfile[ MAXPATHLEN ] = { '\0' }; char dstfile[ MAXPATHLEN ] = { '\0' }; upxfmt_t dst_fmt = DT_UNKNOWN; int ch, rc = 0, debug = 0; FILE* flog = NULL; while( -1 != (ch = getopt(argc, argv, clopt)) ) { switch( ch ) { case 'i': (void)strncpy( srcfile, optarg, sizeof(srcfile) - 1 ); break; case 'o': (void)strncpy( dstfile, optarg, sizeof(dstfile) - 1 ); break; case 't': dst_fmt = DT_TS; break; case 'u': dst_fmt = DT_UDS; break; case 'd': debug = 1; break; default: (void) tmfprintf( stderr, "%s: Unrecognized option [%c]\n", appname, (char)ch ); usage(); return ERR_PARAM; } /* switch */ } /* getopt loop */ if( !srcfile[0] ) { (void) tmfprintf( stderr, "%s: Missing source-file parameter\n", appname ); usage(); return ERR_PARAM; } else { if( 0 != (rc = access( srcfile, R_OK)) ) { perror( "srcfile - access" ); return ERR_PARAM; } } flog = debug ? stderr : fopen( "/dev/null", "a" ); if( NULL == flog ) { perror( "fopen" ); return ERR_INTERNAL; } TRACE( (void)tmfprintf( flog, "%s: destination format = [%s]\n", appname, fmt2str(dst_fmt)) ); if( DT_UNKNOWN == dst_fmt ) { (void)tmfprintf( flog, "%s: destination format must be specified\n", appname ); return ERR_PARAM; } rc = convert2( srcfile, dstfile, dst_fmt, flog ); if( (NULL != flog) && (stderr != flog) ) (void) fclose(flog); return (rc ? ERR_INTERNAL : 0); }