text
stringlengths
8
6.88M
#pragma once #include <SFML/Graphics.hpp> #include "Window.h" #include "Player.h" class Background { static float dynamicBackgroundSpeed; // Prędkość poruszania się tła góra-dół static sf::Texture image; static sf::Sprite background; static sf::Texture image2; static sf::Sprite background2; public: static void render(); // Renderowanie tła static void create(); // Wyświetlanie tła static void animatedBackgroundHorizontal(); // Ruchome tło względem Player'a static void animatedBackgroundVertical(); // Pływające tło góra-dół };
#include <stdio.h> #include <cmath> double fib(int x) { double mult = 1/sqrt(5); double termo = pow((1+sqrt(5))/2,x) - pow((1-sqrt(5))/2,x); return mult*termo; } int main() { int qnt, x; scanf("%d",&qnt); for(int i=0; i<qnt; i++) { scanf("%d", &x); printf("Fib(%d) = %.lf\n", x, fib(x)); } return 0; }
// // trwajacy.cpp // serialowabaza // // Created by Julia on 06.11.2018. // Copyright © 2018 Julia. All rights reserved. // #include <stdio.h> #include "trwajacy.h" #include <fstream> void trwajacy::setemission(int n, int T[]){ IloscOdcinkowTygodniowo=n; typ='T'; DniEmisji=new int[IloscOdcinkowTygodniowo]; for (int i=0;i<IloscOdcinkowTygodniowo;i++) DniEmisji[i]=T[i]; } void trwajacy::save(std::fstream & plik){ try { plik<<"T\n"; serial::save(plik); plik<<IloscOdcinkowTygodniowo<<"\n"; for(int i=0;i<IloscOdcinkowTygodniowo;i++) plik<<DniEmisji[i]<<"\n"; } catch(...){ blad<int> wyzszyblad; wyzszyblad.setmessage(-1); throw wyzszyblad; } } void trwajacy::load(std::fstream & plik){ serial::load(plik); typ='T'; plik>>IloscOdcinkowTygodniowo; DniEmisji= new int[IloscOdcinkowTygodniowo]; for (int i=0; i<IloscOdcinkowTygodniowo;i++) plik>>DniEmisji[i]; plik.close(); } void trwajacy::prezentujsie(){ serial::prezentujsie(); std::cout<<"Jest on emitowany w następujące dni tygodnia: "; for (int i=0 ;i<IloscOdcinkowTygodniowo;i++){ std::cout<<DniEmisji[i]<<", "; } std::cout<<"\n"; }
#pragma once // GcTemplateListCtrl class GcTemplateListCtrl : public CListCtrl { DECLARE_DYNAMIC(GcTemplateListCtrl) protected: int mSelectedItem; CString mSelectedItemText; public: GcTemplateListCtrl(); virtual ~GcTemplateListCtrl(); inline CString& GetSelectedItemText() { return mSelectedItemText; } inline int GetSelectedItem() { return mSelectedItem; } protected: DECLARE_MESSAGE_MAP() public: afx_msg void OnNMClick(NMHDR *pNMHDR, LRESULT *pResult); };
#pragma once #include <cmath> #include <fstream> #include <iostream> #include <string> #include <vector> #include <GL/glew.h> #include <assimp/cimport.h> #include <assimp/postprocess.h> #include <assimp/scene.h> #include <FreeImage.h> struct Texture { BYTE *bits; FIBITMAP *image_ptr; int width; int height; }; class Loader { public: Loader(); ~Loader(); int LoadSceneFromFile(std::string file_name, GLuint& vao, std::vector<GLfloat>& mesh_vertices_count, std::vector<GLfloat>& mesh_starting_vertex_index, std::vector<GLuint>& textures); int loadTexture(std::string file_name, Texture &texture); int LoadTexture(std::string file_name, GLuint& texture_handle); void loadSkybox(std::string front, std::string back, std::string left, std::string right, std::string up, std::string down, GLuint &texture_handle); GLint LoadShaders(std::string vertex_shader, std::string fragment_shader); };
#include <iostream> #include <vector> #include <sstream> #include <fstream> #include <map> using namespace std; // ************************* CITY ************************ const int city_size = 36; string city_list[] = {"Atlanta", "Boston", "Calgary", "Charleston", "Chicago", "Dallas", "Denver", "Duluth", "El_Paso", "Helena", "Houston", "Kansas_City", "Las_Vegas", "Little_Rock", "Los_Angeles", "Miami", "Montreal", "Nashville", "New_Orleans", "New_York", "Oklahoma_City", "Omaha", "Phoenix", "Pittsburgh", "Portland", "Raleigh", "Saint_Louis", "Salt_Lake_City", "San_Francisco", "Santa_Fe", "Sault_St._Marie", "Seattle", "Toronto", "Vancouver", "Washington", "Winnipeg"}; class City { public: int city_num; string name; vector<City*> neighbours; // for Dijkstra's algorithm bool visited; int shortest; int length; // how many roads to build to get here // contructor City(int n) { city_num = n; name = city_list[n]; visited = false; shortest = 2147483647; } }; City* c[36]; // ********************** DISTANCES ********************** map<string, int> distances; bool long_enough; // initiates distances between cities void init_distances() { // TOTAL 78 // ****************** LENGTH 1 ****************** 5 // VANCOUVER - SEATTLE distances[city_list[33] + " - " + city_list[31]] = 1; distances[city_list[31] + " - " + city_list[33]] = 1; // SEATTLE - PORTLAND distances[city_list[31] + " - " + city_list[24]] = 1; distances[city_list[24] + " - " + city_list[31]] = 1; // OMAHA - KANSAS_CITY distances[city_list[21] + " - " + city_list[11]] = 1; distances[city_list[11] + " - " + city_list[21]] = 1; // DALLAS - HOUSTON distances[city_list[5] + " - " + city_list[10]] = 1; distances[city_list[10] + " - " + city_list[5]] = 1; // ATLANTA - NASHVILLE distances[city_list[0] + " - " + city_list[17]] = 1; distances[city_list[17] + " - " + city_list[0]] = 1; // ****************** LENGTH 2 ****************** 25 // LOS_ANGELES - LAS_VEGAS distances[city_list[14] + " - " + city_list[12]] = 2; distances[city_list[12] + " - " + city_list[14]] = 2; // DENVER - SANTA_FE distances[city_list[6] + " - " + city_list[29]] = 2; distances[city_list[29] + " - " + city_list[6]] = 2; // SANTA_FE - EL_PASO distances[city_list[29] + " - " + city_list[8]] = 2; distances[city_list[8] + " - " + city_list[29]] = 2; // DULUTH - OMAHA distances[city_list[7] + " - " + city_list[21]] = 2; distances[city_list[21] + " - " + city_list[7]] = 2; // KANSAS_CITY - OKLAHOMA_CITY distances[city_list[11] + " - " + city_list[20]] = 2; distances[city_list[20] + " - " + city_list[11]] = 2; // OKLAHOMA_CITY - DALLAS distances[city_list[20] + " - " + city_list[5]] = 2; distances[city_list[5] + " - " + city_list[20]] = 2; // KANSAS_CITY - SAINT_LOUIS distances[city_list[11] + " - " + city_list[26]] = 2; distances[city_list[26] + " - " + city_list[11]] = 2; // OKLAHOMA_CITY - LITTLE_ROCK distances[city_list[20] + " - " + city_list[13]] = 2; distances[city_list[13] + " - " + city_list[20]] = 2; // DALLAS - LITTLE_ROCK distances[city_list[5] + " - " + city_list[13]] = 2; distances[city_list[13] + " - " + city_list[5]] = 2; // SAINT_LOUIS - CHICAGO distances[city_list[26] + " - " + city_list[4]] = 2; distances[city_list[4] + " - " + city_list[26]] = 2; // SAINT_LOUIS - LITTLE_ROCK distances[city_list[26] + " - " + city_list[13]] = 2; distances[city_list[13] + " - " + city_list[26]] = 2; // SAINT_LOUIS - NASHVILLE distances[city_list[26] + " - " + city_list[17]] = 2; distances[city_list[17] + " - " + city_list[26]] = 2; // HOUSTON - NEW_ORLEANS distances[city_list[10] + " - " + city_list[18]] = 2; distances[city_list[18] + " - " + city_list[10]] = 2; // SAULT-ST._MARIE - TORONTO distances[city_list[30] + " - " + city_list[32]] = 2; distances[city_list[32] + " - " + city_list[30]] = 2; // TORONTO - PITTSBURGH distances[city_list[32] + " - " + city_list[23]] = 2; distances[city_list[23] + " - " + city_list[32]] = 2; // PITTSBURGH - NEW_YORK distances[city_list[23] + " - " + city_list[19]] = 2; distances[city_list[19] + " - " + city_list[23]] = 2; // PITTSBURGH - WASHINGTON distances[city_list[23] + " - " + city_list[34]] = 2; distances[city_list[34] + " - " + city_list[23]] = 2; // PITTSBURGH - RALEIGH distances[city_list[23] + " - " + city_list[25]] = 2; distances[city_list[25] + " - " + city_list[23]] = 2; // RALEIGH - WASHINGTON distances[city_list[25] + " - " + city_list[34]] = 2; distances[city_list[34] + " - " + city_list[25]] = 2; // RALEIGH - ATLANTA distances[city_list[25] + " - " + city_list[0]] = 2; distances[city_list[0] + " - " + city_list[25]] = 2; // RALEIGH - CHARLESTON distances[city_list[25] + " - " + city_list[3]] = 2; distances[city_list[3] + " - " + city_list[25]] = 2; // CHARLESTON - ATLANTA distances[city_list[3] + " - " + city_list[0]] = 2; distances[city_list[0] + " - " + city_list[3]] = 2; // WASHINGTON - NEW_YORK distances[city_list[34] + " - " + city_list[19]] = 2; distances[city_list[19] + " - " + city_list[34]] = 2; // BOSTON - NEW_YORK distances[city_list[1] + " - " + city_list[19]] = 2; distances[city_list[19] + " - " + city_list[1]] = 2; // BOSTON - MONTREAL distances[city_list[1] + " - " + city_list[16]] = 2; distances[city_list[16] + " - " + city_list[1]] = 2; // ****************** LENGTH 3 ****************** 17 // VANCOUVER - CALGARY distances[city_list[33] + " - " + city_list[2]] = 3; distances[city_list[2] + " - " + city_list[33]] = 3; // SALT_LAKE_CITY - HELENA distances[city_list[27] + " - " + city_list[9]] = 3; distances[city_list[9] + " - " + city_list[27]] = 3; // SALT_LAKE_CITY - DENVER distances[city_list[27] + " - " + city_list[6]] = 3; distances[city_list[6] + " - " + city_list[27]] = 3; // SALT_LAKE_CITY - LAS_VEGAS distances[city_list[27] + " - " + city_list[12]] = 3; distances[city_list[12] + " - " + city_list[27]] = 3; // SAN_FRANCISCO - LOS_ANGELES distances[city_list[28] + " - " + city_list[14]] = 3; distances[city_list[14] + " - " + city_list[28]] = 3; // PHOENIX - LOS_ANGELES distances[city_list[22] + " - " + city_list[14]] = 3; distances[city_list[14] + " - " + city_list[22]] = 3; // PHOENIX - SANTA_FE distances[city_list[22] + " - " + city_list[29]] = 3; distances[city_list[29] + " - " + city_list[22]] = 3; // PHOENIX - EL_PASO distances[city_list[22] + " - " + city_list[8]] = 3; distances[city_list[8] + " - " + city_list[22]] = 3; // SANTA_FE - OKLAHOMA_CITY distances[city_list[29] + " - " + city_list[20]] = 3; distances[city_list[20] + " - " + city_list[29]] = 3; // DULUTH - SAULT_ST._MARIE distances[city_list[7] + " - " + city_list[30]] = 3; distances[city_list[30] + " - " + city_list[7]] = 3; // DULUTH - CHICAGO distances[city_list[7] + " - " + city_list[4]] = 3; distances[city_list[4] + " - " + city_list[7]] = 3; // LITTLE_ROCK - NASHVILLE distances[city_list[13] + " - " + city_list[17]] = 3; distances[city_list[17] + " - " + city_list[13]] = 3; // LITTLE_ROCK - NEW_ORLEANS distances[city_list[13] + " - " + city_list[18]] = 3; distances[city_list[18] + " - " + city_list[13]] = 3; // NASHVILLE - RALEIGH distances[city_list[17] + " - " + city_list[25]] = 3; distances[city_list[25] + " - " + city_list[17]] = 3; // CHICAGO - PITTSBURGH distances[city_list[4] + " - " + city_list[23]] = 3; distances[city_list[23] + " - " + city_list[4]] = 3; // MONTREAL - TORONTO distances[city_list[16] + " - " + city_list[32]] = 3; distances[city_list[32] + " - " + city_list[16]] = 3; // MONTREAL - NEW_YORK distances[city_list[16] + " - " + city_list[19]] = 3; distances[city_list[19] + " - " + city_list[16]] = 3; // ****************** LENGTH 4 ****************** 14 // CALGARY - SEATTLE distances[city_list[2] + " - " + city_list[31]] = 4; distances[city_list[31] + " - " + city_list[2]] = 4; // CALGARY - HELENA distances[city_list[2] + " - " + city_list[9]] = 4; distances[city_list[9] + " - " + city_list[2]] = 4; // WINNIPEG - HELENA distances[city_list[35] + " - " + city_list[9]] = 4; distances[city_list[9] + " - " + city_list[35]] = 4; // WINNIPEG - DULUTH distances[city_list[35] + " - " + city_list[7]] = 4; distances[city_list[7] + " - " + city_list[35]] = 4; // DENVER - HELENA distances[city_list[6] + " - " + city_list[9]] = 4; distances[city_list[9] + " - " + city_list[6]] = 4; // DENVER - OMAHA distances[city_list[6] + " - " + city_list[21]] = 4; distances[city_list[21] + " - " + city_list[6]] = 4; // DENVER - KANSAS_CITY distances[city_list[6] + " - " + city_list[11]] = 4; distances[city_list[11] + " - " + city_list[6]] = 4; // DENVER - OKLAHOMA_CITY distances[city_list[6] + " - " + city_list[20]] = 4; distances[city_list[20] + " - " + city_list[6]] = 4; // EL_PASO - DALLAS distances[city_list[8] + " - " + city_list[5]] = 4; distances[city_list[5] + " - " + city_list[8]] = 4; // CHICAGO - OMAHA distances[city_list[4] + " - " + city_list[21]] = 4; distances[city_list[21] + " - " + city_list[4]] = 4; // CHICAGO - TORONTO distances[city_list[4] + " - " + city_list[32]] = 4; distances[city_list[32] + " - " + city_list[4]] = 4; // NASHVILLE - PITTSBURGH distances[city_list[17] + " - " + city_list[23]] = 4; distances[city_list[23] + " - " + city_list[17]] = 4; // NEW_ORLEANS - ATLANTA distances[city_list[18] + " - " + city_list[0]] = 4; distances[city_list[0] + " - " + city_list[18]] = 4; // CHARLESTON - MIAMI distances[city_list[3] + " - " + city_list[15]] = 4; distances[city_list[15] + " - " + city_list[3]] = 4; // ****************** LENGTH 5 ****************** 8 // SAN_FRANCISCO - PORTLAND distances[city_list[28] + " - " + city_list[24]] = 5; distances[city_list[24] + " - " + city_list[28]] = 5; // SAN_FRANCISCO - SALT_LAKE_CITY distances[city_list[28] + " - " + city_list[27]] = 5; distances[city_list[27] + " - " + city_list[28]] = 5; // PHOENIX - DENVER distances[city_list[22] + " - " + city_list[6]] = 5; distances[city_list[6] + " - " + city_list[22]] = 5; // HELENA - OMAHA distances[city_list[9] + " - " + city_list[21]] = 5; distances[city_list[21] + " - " + city_list[9]] = 5; // EL_PASO - OKLAHOMA_CITY distances[city_list[8] + " - " + city_list[20]] = 5; distances[city_list[20] + " - " + city_list[8]] = 5; // SAULT_ST._MARIE - MONTREAL distances[city_list[30] + " - " + city_list[16]] = 5; distances[city_list[16] + " - " + city_list[30]] = 5; // SAINT_LOUIS - PITTSBURGH distances[city_list[26] + " - " + city_list[23]] = 5; distances[city_list[23] + " - " + city_list[26]] = 5; // ATLANTA - MIAMI distances[city_list[0] + " - " + city_list[15]] = 5; distances[city_list[15] + " - " + city_list[0]] = 5; // ****************** LENGTH 6 ****************** 9 // WINNIPEG - CALGARY distances[city_list[35] + " - " + city_list[2]] = 6; distances[city_list[2] + " - " + city_list[35]] = 6; // WINNIPEG - SAULT_ST._MARIE distances[city_list[35] + " - " + city_list[30]] = 6; distances[city_list[30] + " - " + city_list[35]] = 6; // HELENA - SEATTLE distances[city_list[9] + " - " + city_list[31]] = 6; distances[city_list[31] + " - " + city_list[9]] = 6; // HELENA - DULUTH distances[city_list[9] + " - " + city_list[7]] = 6; distances[city_list[7] + " - " + city_list[9]] = 6; // DULUTH - TORONTO distances[city_list[7] + " - " + city_list[32]] = 6; distances[city_list[32] + " - " + city_list[7]] = 6; // PORTLAND - SALT_LAKE_CITY distances[city_list[24] + " - " + city_list[27]] = 6; distances[city_list[27] + " - " + city_list[24]] = 6; // EL_PASO - LOS_ANGELES distances[city_list[8] + " - " + city_list[14]] = 6; distances[city_list[14] + " - " + city_list[8]] = 6; // EL_PASO - HOUSTON distances[city_list[8] + " - " + city_list[10]] = 6; distances[city_list[10] + " - " + city_list[8]] = 6; // NEW_ORLEANS - MIAMI distances[city_list[18] + " - " + city_list[15]] = 6; distances[city_list[15] + " - " + city_list[18]] = 6; } // initiates cities and their neighbours void init_cities() { for (int i = 0; i < city_size; i++) { c[i] = new City(i); } // ******************** NEIGHBOURS ******************** // 0 ATLANTA c[0]->neighbours.push_back(c[3]); // CHARLESTON c[0]->neighbours.push_back(c[15]); // MIAMI c[0]->neighbours.push_back(c[17]); // NASHVILLE c[0]->neighbours.push_back(c[18]); // NEW_ORLEANS c[0]->neighbours.push_back(c[25]); // RALEIGH // 1 BOSTON c[1]->neighbours.push_back(c[16]); // MONTREAL c[1]->neighbours.push_back(c[19]); // NEW_YORK // 2 CALGARY c[2]->neighbours.push_back(c[9]); // HELENA c[2]->neighbours.push_back(c[31]); // SEATTLE c[2]->neighbours.push_back(c[33]); // VANCOUVER c[2]->neighbours.push_back(c[35]); // WINNIPEG // 3 CHARLESTON c[3]->neighbours.push_back(c[0]); // ATLANTA c[3]->neighbours.push_back(c[15]); // MIAMI c[3]->neighbours.push_back(c[25]); // RALEIGH // 4 CHICAGO c[4]->neighbours.push_back(c[7]); // DULUTH c[4]->neighbours.push_back(c[21]); // OMAHA c[4]->neighbours.push_back(c[23]); // PITTSBURGH c[4]->neighbours.push_back(c[26]); // SAINT_LOUIS c[4]->neighbours.push_back(c[32]); // TORONTO // 5 DALLAS c[5]->neighbours.push_back(c[8]); // EL_PASO c[5]->neighbours.push_back(c[10]); // HOUSTON c[5]->neighbours.push_back(c[13]); // LITTLE_ROCK c[5]->neighbours.push_back(c[20]); // OKLAHOMA_CITY // 6 DENVER c[6]->neighbours.push_back(c[9]); // HELENA c[6]->neighbours.push_back(c[11]); // KANSAS_CITY c[6]->neighbours.push_back(c[20]); // OKLAHOMA_CITY c[6]->neighbours.push_back(c[21]); // OMAHA c[6]->neighbours.push_back(c[22]); // PHOENIX c[6]->neighbours.push_back(c[27]); // SALT_LAKE_CITY c[6]->neighbours.push_back(c[29]); // SANTE_FE // 7 DULUTH c[7]->neighbours.push_back(c[4]); // CHICAGO c[7]->neighbours.push_back(c[9]); // HELENA c[7]->neighbours.push_back(c[21]); // OMAHA c[7]->neighbours.push_back(c[30]); // SAULT_ST._MARIE c[7]->neighbours.push_back(c[32]); // TORONTO c[7]->neighbours.push_back(c[35]); // WINNIPEG // 8 EL_PASO c[8]->neighbours.push_back(c[5]); // DALLAS c[8]->neighbours.push_back(c[10]); // HOUSTON c[8]->neighbours.push_back(c[14]); // LOS_ANGELES c[8]->neighbours.push_back(c[20]); // OKLAHOMA_CITY c[8]->neighbours.push_back(c[22]); // PHOENIX c[8]->neighbours.push_back(c[29]); // SANTA_FE // 9 HELENA c[9]->neighbours.push_back(c[2]); // CALGARY c[9]->neighbours.push_back(c[6]); // DENVER c[9]->neighbours.push_back(c[7]); // DULUTH c[9]->neighbours.push_back(c[21]); // OMAHA c[9]->neighbours.push_back(c[27]); // SALT_LAKE_CITY c[9]->neighbours.push_back(c[31]); // SEATTLE c[9]->neighbours.push_back(c[35]); // WINNIPEG // 10 HOUSTON c[10]->neighbours.push_back(c[5]); // DALLAS c[10]->neighbours.push_back(c[8]); // EL_PASO c[10]->neighbours.push_back(c[18]); // NEW_ORLEANS // 11 KANSAS_CITY c[11]->neighbours.push_back(c[6]); // DENVER c[11]->neighbours.push_back(c[20]); // OKLAHOMA_CITY c[11]->neighbours.push_back(c[21]); // OMAHA c[11]->neighbours.push_back(c[26]); // SAINT_LOUIS // 12 LAS_VEGAS c[12]->neighbours.push_back(c[14]); // LOS_ANGELES c[12]->neighbours.push_back(c[27]); // SALT_LAKE_CITY // 13 LITTLE_ROCK c[13]->neighbours.push_back(c[5]); // DALLAS c[13]->neighbours.push_back(c[17]); // NASHVILLE c[13]->neighbours.push_back(c[18]); // NEW_ORLEANS c[13]->neighbours.push_back(c[20]); // OKLAHOMA_CITY c[13]->neighbours.push_back(c[26]); // SAINT_LOUIS // 14 LOS_ANGELES c[14]->neighbours.push_back(c[8]); // EL_PASO c[14]->neighbours.push_back(c[12]); // LAS_VEGAS c[14]->neighbours.push_back(c[22]); // PHOENIX c[14]->neighbours.push_back(c[28]); // SAN_FRANCISCO // 15 MIAMI c[15]->neighbours.push_back(c[0]); // ATLANTA c[15]->neighbours.push_back(c[3]); // CHARLESTON c[15]->neighbours.push_back(c[18]); // NEW_ORLEANS // 16 MONTREAL c[16]->neighbours.push_back(c[1]); // BOSTON c[16]->neighbours.push_back(c[19]); // NEW_YORK c[16]->neighbours.push_back(c[30]); // SAULT_ST._MARIE c[16]->neighbours.push_back(c[32]); // TORONTO // 17 NASHVILLE c[17]->neighbours.push_back(c[0]); // ATLANTA c[17]->neighbours.push_back(c[13]); // LITTLE_ROCK c[17]->neighbours.push_back(c[23]); // PITTSBURGH c[17]->neighbours.push_back(c[25]); // RALEIGH c[17]->neighbours.push_back(c[26]); // SAINT_LOUIS // 18 NEW_ORLEANS c[18]->neighbours.push_back(c[0]); // ATLANTA c[18]->neighbours.push_back(c[10]); // HOUSTON c[18]->neighbours.push_back(c[13]); // LITTLE_ROCK c[18]->neighbours.push_back(c[15]); // MIAMI // 19 NEW_YORK c[19]->neighbours.push_back(c[1]); // BOSTON c[19]->neighbours.push_back(c[16]); // MONTREAL c[19]->neighbours.push_back(c[23]); // PITTSBURGH c[19]->neighbours.push_back(c[34]); // WASHINGTON // 20 OKLAHOMA_CITY c[20]->neighbours.push_back(c[5]); // DALLAS c[20]->neighbours.push_back(c[6]); // DENVER c[20]->neighbours.push_back(c[8]); // EL_PASO c[20]->neighbours.push_back(c[11]); // KANSAS_CITY c[20]->neighbours.push_back(c[13]); // LITTLE_ROCK c[20]->neighbours.push_back(c[29]); // SANTA_FE // 21 OMAHA c[21]->neighbours.push_back(c[4]); // CHICAGO c[21]->neighbours.push_back(c[6]); // DENVER c[21]->neighbours.push_back(c[7]); // DULUTH c[21]->neighbours.push_back(c[9]); // HELENA c[21]->neighbours.push_back(c[11]); // KANSAS_CITY // 22 PHOENIX c[22]->neighbours.push_back(c[6]); // DENVER c[22]->neighbours.push_back(c[8]); // EL_PASO c[22]->neighbours.push_back(c[14]); // LOS_ANGELES c[22]->neighbours.push_back(c[29]); // SANTA_FE // 23 PITTSBURGH c[23]->neighbours.push_back(c[4]); // CHICAGO c[23]->neighbours.push_back(c[17]); // NASHVILLE c[23]->neighbours.push_back(c[19]); // NEW_YORK c[23]->neighbours.push_back(c[25]); // RALEIGH c[23]->neighbours.push_back(c[26]); // SAINT_LOUIS c[23]->neighbours.push_back(c[32]); // TORONTO c[23]->neighbours.push_back(c[34]); // WASHINGTON // 24 PORTLAND c[24]->neighbours.push_back(c[27]); // SALT_LAKE_CITY c[24]->neighbours.push_back(c[28]); // SAN_FRANCISCO c[24]->neighbours.push_back(c[31]); // SEATTLE // 25 RALEIGH c[25]->neighbours.push_back(c[0]); // ATLANTA c[25]->neighbours.push_back(c[3]); // CHARLESTON c[25]->neighbours.push_back(c[17]); // NASHVILLE c[25]->neighbours.push_back(c[23]); // PITTSBURGH c[25]->neighbours.push_back(c[34]); // WASHINGTON // 26 SAINT_LOUIS c[26]->neighbours.push_back(c[4]); // CHICAGO c[26]->neighbours.push_back(c[11]); // KANSAS_CITY c[26]->neighbours.push_back(c[13]); // LITTLE_ROCK c[26]->neighbours.push_back(c[17]); // NASHVILLE c[26]->neighbours.push_back(c[23]); // PITTSBURGH // 27 SALT_LAKE_CITY c[27]->neighbours.push_back(c[6]); // DENVER c[27]->neighbours.push_back(c[9]); // HELENA c[27]->neighbours.push_back(c[12]); // LAS_VEGAS c[27]->neighbours.push_back(c[24]); // PORTLAND c[27]->neighbours.push_back(c[28]); // SAN_FRANCISCO // 28 SAN_FRANCISCO c[28]->neighbours.push_back(c[14]); // LOS_ANGELES c[28]->neighbours.push_back(c[24]); // PORTLAND c[28]->neighbours.push_back(c[27]); // SALT_LAKE_CITY // 29 SANTA_FE c[29]->neighbours.push_back(c[6]); // DENVER c[29]->neighbours.push_back(c[8]); // EL_PASO c[29]->neighbours.push_back(c[20]); // OKLAHOMA_CITY c[29]->neighbours.push_back(c[22]); // PHOENIX // 30 SAULT_ST._MARIE c[30]->neighbours.push_back(c[7]); // DULUTH c[30]->neighbours.push_back(c[16]); // MONTREAL c[30]->neighbours.push_back(c[32]); // TORONTO c[30]->neighbours.push_back(c[35]); // WINNIPEG // 31 SEATTLE c[31]->neighbours.push_back(c[2]); // CALGARY c[31]->neighbours.push_back(c[9]); // HELENA c[31]->neighbours.push_back(c[24]); // PORTLAND c[31]->neighbours.push_back(c[33]); // VANCOUVER // 32 TORONTO c[32]->neighbours.push_back(c[4]); // CHICAGO c[32]->neighbours.push_back(c[7]); // DULUTH c[32]->neighbours.push_back(c[16]); // MONTREAL c[32]->neighbours.push_back(c[23]); // PITTSBURGH c[32]->neighbours.push_back(c[30]); // SAULT_ST._MARIE // 33 VANCOUVER c[33]->neighbours.push_back(c[2]); // CALGARY c[33]->neighbours.push_back(c[31]); // SEATTLE // 34 WASHINGTON c[34]->neighbours.push_back(c[19]); // NEW_YORK c[34]->neighbours.push_back(c[23]); // PITTSBURGH c[34]->neighbours.push_back(c[25]); // RALEIGH // 35 WINNIPEG c[35]->neighbours.push_back(c[2]); // CALGARY c[35]->neighbours.push_back(c[7]); // DULUTH c[35]->neighbours.push_back(c[9]); // HELENA c[35]->neighbours.push_back(c[30]); // SAULT_ST._MARIE } // resets shortest and visited void reset() { // O(city_size); for (int i = 0; i < city_size; i++) { c[i]->visited = false; c[i]->shortest = 2147483647; } } // finds next city to visit with lowest tentative distance int find_next_city() { // O(city_size) City *c_min = NULL; int min = 2147483647; for (int i = 0; i < city_size; i++) { if (!c[i]->visited && c[i]->shortest < min) { c_min = c[i]; min = c[i]->shortest; } } if (c_min == NULL) cout << "No more neighbours" << endl; return c_min->city_num; } // uses Dijkstra's algorithm to find shortest path from 1 city to another int find_shortest(int cur, int destination) { // O(city_size * (|E| + |V| log|V|)): E = 78, V = 36 // arrived if (cur == destination) { if (c[cur]->length > 1) long_enough = true; return c[cur]->shortest; } City *cur_city = c[cur]; // consider each unvisited neighbour for (vector<City*>::const_iterator it = cur_city->neighbours.begin(); it != cur_city->neighbours.end(); it++) { City *n = *it; // haven't visited city if (!n->visited) { int new_shortest1 = cur_city->shortest + distances[cur_city->name + " - " + n->name]; int new_shortest2 = cur_city->shortest + distances[n->name + " - " + cur_city->name]; // safety if (new_shortest1 != new_shortest2) cout << "FAIL DISTANCES: " << cur_city->name << " and " << n->name << endl; // found new shortest path to that city if (new_shortest1 < n->shortest) { n->shortest = new_shortest1; n->length = cur_city->length + 1; } } } // we have finished visiting this city cur_city->visited = true; // visit next city int next = find_next_city(); return find_shortest(next, destination); } // ********************** THRESHOLDS ********************* // SHORT (threshold1 <= x < threshold2) 4 to 7 // MEDIUM (threshold2 <= x < threshold3) 8 to 14 // LONG (threshold3 <= x) 15 to 23 const int threshold1 = 4; const int threshold2 = 8; const int threshold3 = 15; // finds thresholds void find_threshold() { int max = 0; int min = 2147483647; for (int i = 0; i < city_size - 1; i++) { for (int j = i + 1; j < city_size; j++) { long_enough = false; // i to j reset(); c[i]->shortest = 0; c[i]->length = 0; int distance1 = find_shortest(i, j); cout << c[i]->name << " to " << c[j]->name << ": " << distance1 << endl; // j to i reset(); c[j]->shortest = 0; c[j]->length = 0; int distance2 = find_shortest(j, i); cout << c[j]->name << " to " << c[i]->name << ": " << distance2 << endl; // safety if (distance1 != distance2) cout << "FAILED" << endl; if (distance1 > max) max = distance1; if (distance1 < min) min = distance1; if (long_enough) cout << distance1 << endl; } } cout << "MAX: " << max << endl; cout << "MIN: " << min << endl; } // generates a route with low <= shortest distance < high // length of route must be > 1 string generate(int low, int high) { int src, dst, distance; distance = -1; while (distance < low || high <= distance) { src = rand() % city_size; dst = rand() % city_size; long_enough = false; reset(); c[src]->shortest = 0; c[src]->length = 0; distance = find_shortest(src, dst); // if length == 1 if (!long_enough) distance = -1; } string s = to_string(distance) + " "; if (distance < 10) s += " "; s += c[src]->name + " to " + c[dst]->name; return s; } string players; // # of players // initiates game void init_game() { string short_roads, medium_roads, long_roads; // # players cout << "Enter # of players: "; getline(cin, players); // # short roads cout << "Enter # short roads (length 4 to 7): "; getline(cin, short_roads); // # medium roads cout << "Enter # medium roads (length 8 to 14): "; getline(cin, medium_roads); // # long roads cout << "Enter # long roads (length 15 to 23): "; getline(cin, long_roads); // for each player for (int p = 1; p <= atoi(players.c_str()); p++) { string name; cout << "Enter name of Player " << p << ": "; getline(cin, name); ofstream player(name + ".txt"); player << name << endl; // short roads for (int s = 1; s <= atoi(short_roads.c_str()); s++) { player << " Short Road " << s << ": "; player << generate(threshold1, threshold2) << endl; } // medium roads for (int m = 1; m <= atoi(medium_roads.c_str()); m++) { player << " Medium Road " << m << ": "; player << generate(threshold2, threshold3) << endl; } // long roads for (int l = 1; l <= atoi(long_roads.c_str()); l++) { player << " Long Road " << l << ": "; player << generate(threshold3, 24) << endl; } player.close(); } } // allow teams void teammates() { int t1, t2, teams_num; string teams, team_size, roads, num; cout << endl << "TEAM OBJECTIVES" << endl; cout << "Enter \"y\" or \"n\" if teams: "; getline(cin, teams); // no teams if (teams == "n") cout << "NO TEAMS" << endl; // teams else if (teams == "y") { cout << "How many per team: "; getline(cin, team_size); if (atoi(players.c_str()) % atoi(team_size.c_str()) == 1) { cout << "TEAM NUMBER FAIL" << endl; return; } teams_num = atoi(players.c_str()) / atoi(team_size.c_str()); // type of roads cout << "What type of roads (0 - short, 1 - medium, 2 - long, 3 - any): "; getline(cin, roads); // ************ THRESHOLDS ************ // all short if (roads == "0") { t1 = threshold1; t2 = threshold2; } // all medium else if (roads == "1") { t1 = threshold2; t2 = threshold3; } // all long else if (roads == "2") { t1 = threshold3; t2 = 24; } // any else { t1 = threshold1; t2 = 24; } // # of roads cout << "How many shared objectives: "; getline(cin, num); // for each team for (int t = 1; t <= teams_num; t++) { ofstream team("Team_" + to_string(t) + ".txt"); team << "Team " << to_string(t) << " Shared Objectives" << endl; for (int i = 1; i <= atoi(num.c_str()); i++) { team << " " << generate(t1, t2) << endl; } team.close(); } } // fail answer else cout << "TEAMS FAIL" << endl; } // allow monsters void monsters() { string answer; cout << endl << "Enter \"y\" or \"n\" for monsters: "; getline(cin, answer); // no monsters if (answer == "n") cout << "NO MONSTERS" << endl; // monsters else if (answer == "y") { string line; cout << "How many monsters (1 - 36 monsters): "; getline(cin, line); map<string, bool> city; // where monsters are initialized int num = atoi(line.c_str()); // # of monsters // no monsters if (num == 0) { cout << "NO MONSTERS" << endl; return; } // invalid monster # else if (num < 0 || num > 36) { cout << "MONSTER NUMBER FAIL" << endl; return; } // monsters cout << "Monsters are initialized at:" << endl; while (num > 0) { int next = rand() % city_size; string c = city_list[next]; // found a city if (!city[c]) { city[c] = true; num--; cout << c << endl; } } } // fail answer else cout << "MONSTERS FAIL" << endl; } // player picks more objectives void more_objectives() { string player, roads, num; int t1, t2; // thresholds int x = 0; // extension # cout << endl << "EXTENSION TO GET MORE OBJECTIVES"; while(true) { cout << endl; x++; // player cout << "Enter name of player that wants more objectives or \"q\" to quit: "; getline(cin, player); // quit if (player == "q") break; // type of roads cout << "What type of roads (0 - short, 1 - medium, 2 - long, 3 - any): "; getline(cin, roads); // ************ THRESHOLDS ************ // all short if (roads == "0") { t1 = threshold1; t2 = threshold2; } // all medium else if (roads == "1") { t1 = threshold2; t2 = threshold3; } // all long else if (roads == "2") { t1 = threshold3; t2 = 24; } // any else { t1 = threshold1; t2 = 24; } // # of roads cout << "How many more objectives: "; getline(cin, num); ofstream extend("extend" + to_string(x) + "_" + player + ".txt"); extend << player << " More Objectives" << endl; for (int i = 1; i <= atoi(num.c_str()); i++) { extend << " " << generate(t1, t2) << endl; } extend.close(); } cout << "Game Finished" << endl; } int main() { srand(time(NULL)); init_distances(); init_cities(); // find_threshold(); init_game(); // extensions teammates(); monsters(); more_objectives(); // remove all text files created system("exec rm ./*.txt"); return 0; }
#include "KeyboardBehaviour.h" KeyboardBehaviour::KeyboardBehaviour() { } KeyboardBehaviour::~KeyboardBehaviour() { } vector2 KeyboardBehaviour::Update(Agent* agent, float deltaTime) { aie::Input* input = aie::Input::getInstance(); vector2 force(0, 0); //set up force var float movespeed = 20; //apply movespeed depending of input if (input->isKeyDown(aie::INPUT_KEY_UP)) force.y = movespeed; if (input->isKeyDown(aie::INPUT_KEY_DOWN)) force.y = -movespeed; if (input->isKeyDown(aie::INPUT_KEY_LEFT)) force.x = -movespeed; if (input->isKeyDown(aie::INPUT_KEY_RIGHT)) force.x = movespeed; return force; }
/* * Project BlacBoxHomeDev * Description: * Author: * Date: */ /* * PIR sensor tester */ //Uncommnent the following line to work in offline mode //SYSTEM_MODE(MANUAL); int led = D7; // we will use D7 LED to monitor sensor activity int pir = D0; //connect the PIR output to pin D0 of the Electron void setup() { pinMode(D0, INPUT_PULLDOWN); pinMode(D7,OUTPUT); Particle.publish("state", "DHTxx test start"); blinkitbitch(25, 50); } void loop() { if (digitalRead(D0) == HIGH) { Particle.publish("Motion","Detected",60); //publish an event blinkitbitch(25, 50); delay(1000); while (digitalRead(D0) == HIGH); // wait for the sensor to return back to normal } digitalWrite(D7,LOW); } void blinkitbitch(int times, int counts){ int i; for (int i=1; i <= counts; i++){ digitalWrite(D7, HIGH); delay(times); digitalWrite(D7, LOW); delay(times); } } void checkMotion() { if (digitalRead(D0) == HIGH) { Particle.publish("Motion","Detected",60); //publish an event blinkitbitch(25, 50); delay(1000); while (digitalRead(D0) == HIGH); // wait for the sensor to return back to normal } digitalWrite(D7,LOW); }
#include <cassert> //#include <GL/gl.h> #include <glm/mat4x4.hpp> #include "pbconfig.h" #include "core/pbutil.h" #include "shadercompiler.h" #include "instancedgeometry.h" #include "instancedobject.h" namespace pb { InstancedObject::InstancedObject(const InstancedObject& rhs) : InstancedObject() { //obj = rhs; mpGeometry = rhs.mpGeometry; mId = mpGeometry->AddInstance(); } InstancedObject::InstancedObject() : mId( 0 ), mpGeometry( NULL ) { //mStatus = init(); mStatus = PB_ERR; } InstancedObject::~InstancedObject() { // TODO //PB_DELETE( mpTransform ); <- mesh owns thetransform //PB_DELETE( mpGeometry ); } void InstancedObject::Make(InstancedObject* pObj, unsigned int hintPerInstanceTableSize) { pObj->mHintPerInstanceTableSize = hintPerInstanceTableSize; pObj->mStatus = pObj->init(); } //void InstancedObject::MakeAnother(const InstancedObject& alpha, InstancedObject& another) //{ // another.mpGeometry = alpha.mpGeometry; // another.mId = another.mpGeometry->AddInstance(); //// another.mpTransform = another.mpGeometry->Transform( another.mId ); //} PBError InstancedObject::init() { return PB_ERR_OK; } void InstancedObject::Update() { if ( transformDirty() ) { computeTransform(); } } void InstancedObject::Draw(const glm::mat4& vp) { // should be carried out by alpha instance only assert( mId == 0 ); if ( Visible() ) { mpGeometry->Render( vp ); } } void InstancedObject::computeTransform() { if ( transformDirty() ) { Object::computeTransform(); if ( Visible() ) { updateTransformAttrib(); } } } }
// ScheduleDlg.cpp : 实现文件 // #include "stdafx.h" #include "Schedule.h" #include "ScheduleDlg.h" #include "afxdialogex.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // 用于应用程序“关于”菜单项的 CAboutDlg 对话框 class CAboutDlg : public CDialogEx { public: CAboutDlg(); // 对话框数据 enum { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 // 实现 protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) END_MESSAGE_MAP() // CScheduleDlg 对话框 CScheduleDlg::CScheduleDlg(CWnd* pParent /*=NULL*/) : CDialogEx(CScheduleDlg::IDD, pParent) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CScheduleDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_TAB1, m_tab); } BEGIN_MESSAGE_MAP(CScheduleDlg, CDialogEx) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_WM_CTLCOLOR() ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, &CScheduleDlg::OnTcnSelchangeTab1) END_MESSAGE_MAP() // CScheduleDlg 消息处理程序 BOOL CScheduleDlg::OnInitDialog() { CDialogEx::OnInitDialog(); // 将“关于...”菜单项添加到系统菜单中。 // IDM_ABOUTBOX 必须在系统命令范围内。 ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { BOOL bNameValid; CString strAboutMenu; bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); ASSERT(bNameValid); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 // 执行此操作 SetIcon(m_hIcon, TRUE); // 设置大图标 SetIcon(m_hIcon, FALSE); // 设置小图标 // TODO: 在此添加额外的初始化代码 CDialog::OnInitDialog(); //初始化m_tab控件上的属性页标签 m_tab.InsertItem(0,_T("Duty chart 1")); m_tab.InsertItem(1,_T("Duty chart 2")); m_tab.InsertItem(2,_T("Duty chart 3")); m_tab.InsertItem(3,_T("Employee Info")); m_tab.InsertItem(4,_T("Others")); //创建属性页; m_pg1.Create(IDD_DIALOG1,GetDlgItem(IDC_TAB1)); m_pg2.Create(IDD_DIALOG2,GetDlgItem(IDC_TAB1)); m_pg3.Create(IDD_DIALOG3,GetDlgItem(IDC_TAB1)); m_pg4.Create(IDD_DIALOG4,GetDlgItem(IDC_TAB1)); m_pg5.Create(IDD_DIALOG5,GetDlgItem(IDC_TAB1)); //获取TAB的客户端矩形框,从而设置各属性页在TAB上的物理位置 CRect rs; m_tab.GetClientRect(&rs); rs.top+=20; rs.bottom-=4; rs.left+=4; rs.right-=4; //设置属性页的大小和位置 m_pg1.MoveWindow(&rs); m_pg2.MoveWindow(&rs); m_pg3.MoveWindow(&rs); m_pg4.MoveWindow(&rs); m_pg5.MoveWindow(&rs); //默认第一页显示 m_pg1.ShowWindow(TRUE); m_tab.SetCurSel(0); return TRUE; // 除非将焦点设置到控件,否则返回 TRUE } void CScheduleDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialogEx::OnSysCommand(nID, lParam); } } // 如果向对话框添加最小化按钮,则需要下面的代码 // 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序, // 这将由框架自动完成。 void CScheduleDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // 用于绘制的设备上下文 SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); // 使图标在工作区矩形中居中 int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // 绘制图标 dc.DrawIcon(x, y, m_hIcon); } else { CDialogEx::OnPaint(); } } //当用户拖动最小化窗口时系统调用此函数取得光标 //显示。 HCURSOR CScheduleDlg::OnQueryDragIcon() { return static_cast<HCURSOR>(m_hIcon); } HBRUSH CScheduleDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: 在此更改 DC 的任何特性 // TODO: 如果默认的不是所需画笔,则返回另一个画笔 return hbr; } void CScheduleDlg::OnTcnSelchangeTab1(NMHDR *pNMHDR, LRESULT *pResult) { // TODO: 在此添加控件通知处理程序代码 //根据当前TAB上的选择来显示属性页 switch(m_tab.GetCurSel()) { case 0: m_pg1.ShowWindow(TRUE); m_pg2.ShowWindow(FALSE); m_pg3.ShowWindow(FALSE); m_pg4.ShowWindow(FALSE); m_pg5.ShowWindow(FALSE); break; case 1: m_pg1.ShowWindow(FALSE); m_pg2.ShowWindow(TRUE); m_pg3.ShowWindow(FALSE); m_pg4.ShowWindow(FALSE); m_pg5.ShowWindow(FALSE); break; case 2: m_pg1.ShowWindow(FALSE); m_pg2.ShowWindow(FALSE); m_pg3.ShowWindow(TRUE); m_pg4.ShowWindow(FALSE); m_pg5.ShowWindow(FALSE); break; case 3: m_pg1.ShowWindow(FALSE); m_pg2.ShowWindow(FALSE); m_pg3.ShowWindow(FALSE); m_pg4.ShowWindow(TRUE); m_pg5.ShowWindow(FALSE); break; case 4: m_pg1.ShowWindow(FALSE); m_pg2.ShowWindow(FALSE); m_pg3.ShowWindow(FALSE); m_pg4.ShowWindow(FALSE); m_pg5.ShowWindow(TRUE); break; default: ; } *pResult = 0; }
// // Created by 송지원 on 2020/07/04. // #include <iostream> #include <vector> using namespace std; int main() { vector<pair<int,int>> V; int temp; int max = -1; int maxIndex; for (int i=0; i<9; i++) { cin >> temp; if (temp > max) { max = temp; maxIndex = i; } V.push_back({temp, i+1}); } cout << V.at(maxIndex).first << "\n" <<V.at(maxIndex).second; }
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- ** ** Copyright (C) 1995-2012 Opera Software ASA. All rights reserved. ** ** This file is part of the Opera web browser. It may not be distributed ** under any circumstances. */ #ifndef DOM_EXTENSIONS_MENUTEM_PROXY_H #define DOM_EXTENSIONS_MENUTEM_PROXY_H #ifdef DOM_EXTENSIONS_CONTEXT_MENU_API_SUPPORT #include "modules/dom/src/domobj.h" #include "modules/dom/src/extensions/domextensionsupport.h" #include "modules/windowcommander/OpWindowCommander.h" #include "modules/doc/externalinlinelistener.h" class DocumentMenuItem; class ShownExtensionMenu; class DOM_ExtensionMenuContextProxy; /** Class representing MenuItem in UserJS. * * Currently only used as a target for onclick events * on opera.context.menu object. */ class DOM_ExtensionMenuItemProxy : public DOM_Object { public: ~DOM_ExtensionMenuItemProxy(); static OP_STATUS Make(DOM_ExtensionMenuItemProxy*& new_obj , DOM_ExtensionSupport* extension , DOM_ExtensionMenuContextProxy* top_level_context , UINT referred_item_id , const uni_char* item_js_id , DOM_Runtime* origining_runtime); /* from DOM_Object */ virtual ES_GetState GetName(const uni_char* property_name, int property_atom, ES_Value* value, ES_Runtime* origining_runtime); virtual ES_GetState GetName(OpAtom property_atom, ES_Value* value, ES_Runtime* origining_runtime); virtual ES_PutState PutName(const uni_char* property_name, int property_atom, ES_Value* value, ES_Runtime* origining_runtime); virtual ES_PutState PutName(OpAtom property_atom, ES_Value* value, ES_Runtime* origining_runtime); virtual BOOL IsA(int type) { return type == DOM_TYPE_EXTENSION_MENUITEM_PROXY || DOM_Object::IsA(type); } BOOL GetIsSignificant(); void OnTopLevelContextDestroyed(); private: DOM_ExtensionMenuItemProxy(DOM_ExtensionSupport* extension_support, DOM_ExtensionMenuContextProxy* top_level_context, UINT referred_item_id); DOM_ExtensionMenuContextProxy* m_top_level_context; UINT32 m_item_id; // Internal id of menu item. OpString m_id; // String id visible in js. BOOL m_is_significant; OpSmartPointerWithDelete<DOM_ExtensionSupport> m_extension_support; }; #endif // DOM_EXTENSIONS_CONTEXT_MENU_API_SUPPORT #endif // !DOM_EXTENSIONS_MENUTEM_PROXY_H
#include <bits/stdc++.h> using namespace std; int main(){ int N , K; cin >> N >> K; int d; int x; //x(x <N)番目の人がお菓子をもらう set<int> S; //お菓子を持っている人の番号を入れるset for(int i = 1; i<= K; i++){ //K種類のお菓子の cin >> d; for(int j = 1; j <= d; j++){ //i種目のお菓子を持っている人 cin >> x; S.insert(x); } } int y = S.size(); //お菓子を1つ以上持っている人数 cout << N - y<< endl; }
#ifndef VIRTUALSCREEN_H #define VIRTUALSCREEN_H #include <SFML/Graphics.hpp> class VirtualScreen : public sf::RenderTexture { public: VirtualScreen(unsigned int width, unsigned int height); void worldDraw(sf::Sprite& sprite, const sf::Vector2f& position); void pixelDraw(sf::Sprite& sprite, const sf::Vector2f& position); private: virtual sf::Vector2f getPixelPosition(const sf::Vector2f& worldPos); }; #endif
//dp[i] is set to true if a valid word (word sequence) ends at i-1. class Solution { public: bool wordBreak(string s, vector<string>& wordDict) { if(wordDict.size() == 0) return false; unordered_set<string> dict; int maxLen = 0; for(string s: wordDict){ dict.insert(s); if(s.size() > maxLen) maxLen = s.size(); //use maxLen to shorten time } vector<bool> dp(s.size()+1, false); dp[0] = true; for(int i = 1; i <= s.size(); ++i){ for(int j = i-1; j >= max(i-maxLen, 0); --j){ if(dp[j]){ string word = s.substr(j, i-j); if(dict.find(word) != dict.end()){ dp[i] = true; break; } } } } return dp[s.size()]; } };
unsigned int adc; void setup(){ Serial.begin(115200); Serial.setDebugOutput(true); Serial.printf("Iniciando...\n"); pinMode(2, OUTPUT); digitalWrite(2, LOW); delay(100); } void setup(){ adc=0; pinMode(2,INPUT); while(digitalRead(2) == LOW) adc++; Serial.printf("%i\n", adc); pinMode(2, OUTPUT); digitalWrite(2, LOW); delay(100); }
#include "csvreader.h" #include "ui_csvreader.h" CsvReader::CsvReader(QWidget *parent) : QMainWindow(parent), ui(new Ui::CsvReader) { ui->setupUi(this); ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); } CsvReader::~CsvReader() { delete ui; } void CsvReader::on_action_Open_triggered() { csvModel = new QStandardItemModel(this); // Set model ui->tableView->setModel(csvModel); // Get filename QString filename = QFileDialog::getOpenFileName(this, "Open CSV File", QDir::currentPath(), tr("Files (*.csv)")); QFile file(filename); if ( !file.open(QFile::ReadOnly | QFile::Text) ) { qDebug() << "File not exists"; } else { // Create a textstream to retrieve data from a file QTextStream in(&file); // Reads the data up to the end of file while (!in.atEnd()){ QString line = in.readLine(); // Adding to the model in line with the elements QList<QStandardItem *> standardItemsList; // consider that the line is separated by commas into columns // fixme: hard coded delimiter for (QString item : line.split(",")) { standardItemsList.append(new QStandardItem(item)); } csvModel->insertRow(csvModel->rowCount(), standardItemsList); } } file.close(); }
#include "freego.h" namespace logging = boost::log; namespace src = boost::log::sources; namespace sinks = boost::log::sinks; namespace keywords = boost::log::keywords; FreeGo* FreeGo::instance_ = 0; FreeGo* FreeGo::instance() { if(!instance_) { instance_ = new FreeGo; instance_->init(); } return instance_; } void FreeGo::init() { boost::log::add_file_log ( boost::log::keywords::file_name = "cxx_%N.log", boost::log::keywords::rotation_size = 10 * 1024 * 1024, boost::log::keywords::time_based_rotation = boost::log::sinks::file::rotation_at_time_point(0, 0, 0), boost::log::keywords::auto_flush = true, boost::log::keywords::format = "[%TimeStamp%]: %Message%" ); logging::core::get()->set_filter ( logging::trivial::severity >= logging::trivial::trace ); logging::add_common_attributes(); }
#include <iostream> #include <cmath> #include "head.h" using namespace std; int main() { cout << "x = " << x << endl; calculate(); cout << round(result * 10000) / 10000 << endl; cout << "Vvod x:"; cin >> x; calculate(); cout << round(result * 10000) / 10000 << endl; system("PAUSE"); return 0; }
#ifndef _VECTOR3_HPP_ #define _VECTOR3_HPP_ #pragma once #include <cmath> #include <string> class Vector3 { public: float x; float y; float z; Vector3(float x = 0, float y = 0, float z = 0); void normalize(); std::string ToString(); static float DotProduct(const Vector3 &a, const Vector3 &b); static Vector3 CrossProduct(const Vector3 &a, const Vector3 &b); static void PlaneEcuation(float *planeEcuation, const Vector3 &a, const Vector3 &b, const Vector3 &c); Vector3 &operator+=(const Vector3 &rhs); Vector3 &operator-=(const Vector3 &rhs); friend bool operator==(const Vector3 &a, const Vector3 &b); friend bool operator!=(const Vector3 &a, const Vector3 &b); friend Vector3 operator+(Vector3 lhs, const Vector3 &rhs); friend Vector3 operator-(Vector3 lhs, const Vector3 &rhs); }; #endif
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- ** ** Copyright (C) 2011 Opera Software ASA. All rights reserved. ** ** This file is part of the Opera web browser. It may not be distributed ** under any circumstances. */ #ifndef GEOLOCATION_NEW_NETWORK_API_RESPONSE_PARSER_H #define GEOLOCATION_NEW_NETWORK_API_RESPONSE_PARSER_H #ifdef GEOLOCATION_SUPPORT #include "modules/ecmascript/json_listener.h" class Google2011NetworkApiResponseParser : public JSONListener { public: enum Status { NO_STATUS, ///< There was no status in the response. OK, ///< Success, latitude and logitude should be present. REQUEST_DENIED, ///< Request denied. INVALID_REQUEST, ///< The request was invalid. ZERO_RESULTS, ///< No results (I have no idea what that means). OVER_QUERY_LIMIT ///< Query limit (per IP per day) has been reached. }; Google2011NetworkApiResponseParser(); /** Return status from the response. */ Status GetStatus() const { return m_response_status; } /** Return the accuracy. * * @return Accuracy in meters or NaN if there was no accuracy information in the response. */ double GetAccuracy() const { return m_accuracy; } /** Return the latitude. * * @return Latitude in degrees or NaN if there was no latitude data in the response. */ double GetLatitude() const { return m_latitude; } /** Return the longitude. * * @return Longitude in degrees or NaN if there was no longitude data in the response. */ double GetLongitude() const { return m_longitude; } const uni_char* GetAccessToken() const { return m_access_token.CStr(); } // From JSONListener virtual OP_STATUS EnterArray() { return PushState(UNKNOWN_ARRAY); } virtual OP_STATUS LeaveArray() { return LeaveObject(); } virtual OP_STATUS EnterObject(); virtual OP_STATUS LeaveObject(); virtual OP_STATUS AttributeName(const OpString& attribute); // Values virtual OP_STATUS String(const OpString& string); virtual OP_STATUS Number(double num); virtual OP_STATUS Bool(BOOL val) { return PopAttributeState(); } virtual OP_STATUS Null() { return PopAttributeState(); } private: enum State { UNKNOWN_ARRAY, UNKNOWN_OBJECT, MAIN_OBJECT, LOCATION_OBJECT, // Attributes FIRST_ATTRIBUTE, UNKNOWN_ATTRIBUTE = FIRST_ATTRIBUTE, STATUS, ACCURACY, LOCATION, LAT, LNG, ACCESS_TOKEN }; BOOL IsAttributeState(State s) const { return s >= FIRST_ATTRIBUTE; } enum { MAX_STATE_STACK_SIZE = 32 }; OP_STATUS PushState(State state); OP_STATUS PopState(); OP_STATUS PopAttributeState(); State m_state_stack[MAX_STATE_STACK_SIZE]; unsigned m_state_stack_size; Status m_response_status; double m_accuracy; double m_latitude; double m_longitude; OpString m_access_token; }; #endif // GEOLOCATION_SUPPORT #endif // GEOLOCATION_NEW_NETWORK_API_RESPONSE_PARSER_H
/********************************************************************************** General Eyelid Header file Has overall class definition and private and public functions Edited by Ethan Lauer on 10/9/19 *********************************************************************************/ #include <Arduino.h> class Eyelid { private: // Servo Pins int topLidPin; int botLidPin; // SERVO POSITIONS int botClosePos; int botOpenPos; int topClosePos; int topOpenPos; //left or right eyelid bool isLeft; //Servo Type int servoType; int cmdLid = 0; int stepLidState = 0; public: //***********************************************SETUP AND INITIALIZE************************************************* // Define the eyelid Eyelid() { } void setUp(bool isLeft, int servoType) { isLeft = isLeft; servoType = servoType; if (isLeft) { //left eye lids // Set servo pins topLidPin = topEyelidL; botLidPin = botEyelidL; //Bottom Servo Positions botClosePos = 97; botOpenPos = 113; //Top Servo Positions topClosePos = 135; topOpenPos = 75; } else { //right lids // Set servo pins topLidPin = topEyelidR; botLidPin = botEyelidR; //Bottom Servo Positions botClosePos = 133; botOpenPos = 115; //Top Servo Positions topClosePos = 60; topOpenPos = 125; } Serial.println("Initializing Eyelids"); } //***********************************************SET POSITION************************************************* /* moveTopLidTo - move top lid to a set servo position int servoPos - servo position of the top servo */ void moveTopLidTo(int servoPos) { driveServo(topLidPin, servoPos, servoType); } /* moveBotLidTo - move bot lid to a set servo position int servoPos - servo position of the top servo */ void moveBotLidTo(int servoPos) { driveServo(botLidPin, servoPos, servoType); } /* openLidPercent -open the lids float percent - percentage they eyes are set to be open (ie. 75 is 75% open eyes) based on the open and closed position of both the top and bottom servos find the position of the "percentage point". once that point is found withing that range, add it to top/bottom positions to it moves in reference to the top or bottom. drive the servos */ void openLidPercent(float percent) { int topPos; int botPos; if (isLeft) { // calcualted top and bottom positions topPos = (int) (-1 * ((topClosePos - topOpenPos) * (percent / 100))); botPos = (int) ((botOpenPos - botClosePos) * (percent / 100)); topPos = topClosePos + topPos; botPos = botClosePos + botPos; // Drive the servos moveTopLidTo(topPos); moveBotLidTo(botPos); } else { // calcualted top and bottom positions topPos = (int) ((topOpenPos - topClosePos) * (percent / 100)); botPos = (int) (-1 * ((botClosePos - botOpenPos) * (percent / 100))); topPos = topClosePos + topPos; botPos = botClosePos + botPos; // Drive the servos moveTopLidTo(topPos); moveBotLidTo(botPos); } } /* closeEyelid - close the eyelids */ void closeEyelid() { moveTopLidTo(topClosePos); moveBotLidTo(botClosePos); } /* openEyelid- open the eyelid */ void openEyelid() { moveTopLidTo(topOpenPos); moveBotLidTo(botOpenPos); } //***********************************************DYNAMIC MOVEMENTS************************************************* /* stepLidOpenClose - slowly open and close the eyelid unsigned long timeNow - time in milliseconds so can count if need to increment eyes int moveTime - time it takes to move the servo float percent - how much to open the eyelid int degChangeOpen - the number of degrees the eyelids should move at a time when opening int degChangeClose - the number of degrees the eyelids should move at a time when closing */ void stepLidOpenClose(unsigned long timeNow, int moveTime, float percent, int degChangeOpen, int degChangeClose) { switch (stepLidState) { case 0: openLidPercent(cmdLid); if (millis() > timeNow + moveTime && cmdLid != percent) { cmdLid += degChangeOpen; timeNow = millis(); } else if (cmdLid == percent) { stepLidState = 1; } break; case 1: openLidPercent(cmdLid); if (millis() > timeNow + moveTime && cmdLid != 0) { cmdLid -= degChangeClose; timeNow = millis(); } else if (cmdLid == 0) { stepLidState = 0; } break; } } };
#pragma once #include <cmath> namespace functions { double k_1_test(double x) { return 1 / 2.25; } double k_2_test(double x) { return 4; } double q_1_test(double x) { return 1; } double q_2_test(double x) { return 1; } double f_1_test(double x) { return 0; } double f_2_test(double x) { return 1; } double k_1_main(double x) { return pow(x + 1, 2); } double k_2_main(double x) { return pow(x, 2); } double q_1_main(double x) { return exp(-x) * exp(0.5); } double q_2_main(double x) { return exp(x) / exp(0.5); } double f_1_main(double x) { return cos(M_PI * x); } double f_2_main(double x) { return 1; } double u_1_test(double x) { return 0.06393352077249962 * (-exp(-(2. / 3.) * x) + exp((2. / 3.) * x)); } double u_2_test(double x) { return -0.1014378993911736 * exp(2. * x) - 1.850734448924362 * exp(-2. * x) + 1; } }
#include <iostream> #include <opencv2/opencv.hpp> using namespace cv; using namespace std; int main(int, char**){ Mat image; Vec3b val; Size tamanho; int p1[2], p2[2]; //Ponto 1 e ponto 2, respectivamente int altura, largura; image = imread("biel.png", CV_LOAD_IMAGE_GRAYSCALE); if(!image.data){ cout << "Não foi possível abrir a imagem" << endl; exit(1); } namedWindow("janela", WINDOW_AUTOSIZE); namedWindow("janela_negativo", WINDOW_AUTOSIZE); imshow("janela", image); tamanho = image.size(); altura = tamanho.height; largura = tamanho.width; //Inserção das coordenadas do primeiro ponto cout << "Insira as coordenadas do ponto 1 (X, Y): "; cin >> p1[0] >> p1[1]; //Caso os valores de P1 inseridos sejam inválidos, fechamos o programa if(p1[0] < 0 || p1[0] > altura || p1[1] < 0 || p1[1] > largura){ cout << "Valores de ponto incorretos, encerrando programa..."; exit(1); } //Inserção das coordenadas do segundo ponto cout << "Insira as coordenadas do ponto 2 (X, Y): "; cin >> p2[0] >> p2[1]; //Caso os valores inseridos sejam inválidos, fechamos o programa if(p2[0] < 0 || p2[0] > altura || p2[1] < 0 || p2[1] > largura){ cout << "Valores de ponto incorretos, encerrando programa..."; exit(1); } for(int i = p1[0]; i < p2[0]; i++){ for(int j = p1[1]; j < p2[1]; j++){ image.at<uchar>(i,j) = 255 - image.at<uchar>(i,j); } } imshow("janela_negativo", image); waitKey(); return 0; }
//with C's I/O and C++'s string class #include<cstdio> #include<cstring> #include<iostream> #include<string> using namespace std; class save{ public: string identity; int test_number; int seat_number; }; int main(){ //input save give_data[1005]; int quantity; scanf("%d\n",&quantity); char temp1[15]; int temp2; int temp3; for(int i=0;i<quantity;++i){ scanf("%s %d %d\n",&temp1,&temp2,&temp3); give_data[temp2].identity = temp1; give_data[temp2].test_number = temp2; give_data[temp2].seat_number = temp3; } //deal with and output scanf("%d\n",&quantity); int target; for(int i=0;i<quantity;++i){ scanf("%d",&target); printf("%s %d\n",give_data[target].identity.c_str(),give_data[target].seat_number); } return 0; } //1. 17line >=1000 i use 1000, but i want to know when to use that and when to use new /* //with C++'s I/O and string class #include<iostream> #include<string> using namespace std; class save{ public: string identity; int test_number; int seat_number; }; int main(){ //input save give_data[1005]; save temp; int quantity; cin>>quantity; for(int i=0;i<quantity;++i){ cin>>temp.identity>>temp.test_number>>temp.seat_number; //scanf("%s %d %d\n",&temp.identity,&temp.test_number,&temp.seat_number); give_data[temp.test_number].identity = temp.identity; give_data[temp.test_number].test_number = temp.test_number; give_data[temp.test_number].seat_number = temp.seat_number; } cin>>quantity; //deal with and output int target; for(int i=0;i<quantity;++i){ cin>>target; cout<<give_data[target].identity<<' '<<give_data[target].seat_number<<endl; } return 0; } */ /* // with C++'s I/O and String class #include<cstdio> #include<cstring> using namespace std; class save{ public: char *identity; int test_number; int seat_number; }; int main(){ //input save give_data[1005]; save temp; int quantity; scanf("%d\n",&quantity); for(int i=0;i<quantity;++i){ scanf("%s %d %d\n",&temp.identity,&temp.test_number,&temp.seat_number); strcpy(give_data[temp.test_number].identity,temp.identity); //give_data[temp.test_number].identity = temp.identity; give_data[temp.test_number].test_number = temp.test_number; give_data[temp.test_number].seat_number = temp.seat_number; } scanf("%d\n",&quantity); //deal with and output int target; while(scanf("%d",&target)){ printf("%s %d\n",give_data[target].identity,give_data[target].seat_number); } return 0; } */
class Solution { public: int singleNumber(vector<int>& nums) { int len = nums.size(); if(len<1) return 0; sort(nums.begin(),nums.end()); int num = nums[0]; for(int i=1;i<len;i+=2){ if(num==nums[i]){ num = nums[i+1]; }else{ return num; } } return num; } };
/* XMRig * Copyright 2008-2018 Advanced Micro Devices, Inc. * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef XMRIG_ADLLIB_H #define XMRIG_ADLLIB_H #include "backend/opencl/wrappers/AdlHealth.h" namespace xmrig { class OclDevice; class AdlLib { public: static bool init(); static const char *lastError() noexcept; static void close(); static AdlHealth health(const OclDevice &device); static inline bool isInitialized() noexcept { return m_initialized; } static inline bool isReady() noexcept { return m_ready; } private: static bool dlopen(); static bool load(); static bool m_initialized; static bool m_ready; }; } // namespace xmrig #endif /* XMRIG_ADLLIB_H */
/*Дано трехзначное число. Проверить истинность высказывания: «Все цифры данного числа различны». */ #include <iostream> using namespace std; int main() { cout << "Write down number" << endl; int a; cin >> a ; int x = a / 100, y = (a / 10) % 10 , z = a % 10; if ((x != y) && (y != z) && (z != x)){ /* Можно и без if просто вывести условие и будет выдавать 1(да) или 0(нет)*/ cout << "Yes"; } else { cout << "No"; } return 0; }
/** * @section LICENSE * * Copyright (c) 2013 @tosihisa, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * @section DESCRIPTION * * Fingerprint reader module "GT-511C3" class. * * http://www.adh-tech.com.tw/?22,gt-511c3-gt-511c31 * http://www.adh-tech.com.tw/files/GT-511C3_datasheet_V1%201_20131127[1].pdf * https://www.sparkfun.com/products/11792 * https://github.com/sparkfun/Fingerprint_Scanner-TTL/ */ #include "mbed.h" #include "GT521FX.hpp" #define SET_AND_SUMADD(idx,val) sendbuf[idx]=(( char)(val));sum += sendbuf[idx] int GT521FX::Init(void) { baud(9600); ClearLine(); return 0; } int GT521FX::SendCommand( long Parameter, short Command) { char sendbuf[12]; short sum = 0; int idx = 0; int i; SET_AND_SUMADD(idx,0x55); idx++; SET_AND_SUMADD(idx,0xAA); idx++; SET_AND_SUMADD(idx,0x01); idx++; SET_AND_SUMADD(idx,0x00); idx++; SET_AND_SUMADD(idx,Parameter & 0xff); idx++; SET_AND_SUMADD(idx,(Parameter >> 8) & 0xff); idx++; SET_AND_SUMADD(idx,(Parameter >> 16) & 0xff); idx++; SET_AND_SUMADD(idx,(Parameter >> 24) & 0xff); idx++; SET_AND_SUMADD(idx,Command & 0xff); idx++; SET_AND_SUMADD(idx,(Command >> 8) & 0xff); idx++; sendbuf[idx] = sum & 0xff; idx++; sendbuf[idx] = (sum >> 8) & 0xff; idx++; for(i = 0; i < idx; i++) { while(!writeable()); putc(sendbuf[i]); } return 0; } int GT521FX::RecvResponse( long *Parameter, short *Response) { const char fixedbuf[4] = { 0x55,0xAA,0x01,0x00 }; char buf[12]; short sum = 0; int i; *Parameter = 0; *Response = CMD_Nack; for(i = 0; i < sizeof(buf); i++) { while(!readable()); buf[i] = getc(); if(i < 9) { sum += buf[i]; } if(i < 4) { if(buf[i] != fixedbuf[i]) { return -1; } } } if(buf[10] != (sum & 0xff)) return -2; if(buf[11] != ((sum >> 8) & 0xff)) return -2; *Parameter = buf[7]; *Parameter = (*Parameter << 8) | buf[6]; *Parameter = (*Parameter << 8) | buf[5]; *Parameter = (*Parameter << 8) | buf[4]; *Response = buf[9]; *Response = (*Response << 8) | buf[8]; return 0; } int GT521FX::SendData( char *data, long size) { const char fixedbuf[4] = { 0x5A,0xA5,0x01,0x00 }; short sum = 0; int i; for(i = 0;i < 4;i++){ while(!writeable()); putc(fixedbuf[i]); sum += fixedbuf[i]; } for(i = 0;i < size;i++){ while(!writeable()); putc(data[i]); sum += data[i]; } while(!writeable()); putc(( char)(sum & 0xff)); while(!writeable()); putc(( char)((sum >> 8) & 0xff)); return 0; } int GT521FX::RecvData( char *data, long size) { const char fixedbuf[4] = { 0x5A,0xA5,0x01,0x00 }; short sum = 0; int i; for(i = 0; i < size; i++) { while(!readable()); *(data + i) = getc(); if(i < (size-2)) { sum += *(data + i); } if(i < 4) { if(*(data + i) != fixedbuf[i]) { return -1; } } } if(*(data + size - 2) != (sum & 0xff)) return -2; if(*(data + size - 1) != ((sum >> 8) & 0xff)) return -2; return 0; } int GT521FX::SendRecv( short Command, long *Parameter, short *Response) { int sts; if((sts = SendCommand(*Parameter,Command)) == 0) { *Parameter = 0; if((sts = RecvResponse(Parameter,Response)) != 0) { *Response = CMD_Nack; *Parameter = NACK_IO_ERR; } } if(*Response == CMD_Nack) { LastError = *Parameter; } return sts; } int GT521FX::ClearLine(void) { while(readable()) { (void)getc(); } return 0; } int GT521FX::Open(void) { long Parameter = 1; short Response = 0; char buf[4+sizeof(FirmwareVersion)+sizeof(IsoAreaMaxSize)+sizeof(DeviceSerialNumber)+2]; int sts = 0; if((sts = Init()) != 0) return -1; sts = SendRecv(CMD_Open,&Parameter,&Response); if((sts != 0) || (Response != CMD_Ack)) { return -1; } if((sts = RecvData(buf,sizeof(buf))) == 0) { memcpy(&FirmwareVersion,&buf[4+0],sizeof(FirmwareVersion)); memcpy(&IsoAreaMaxSize,&buf[4+sizeof(FirmwareVersion)],sizeof(IsoAreaMaxSize)); memcpy(DeviceSerialNumber,&buf[4+sizeof(FirmwareVersion)+sizeof(IsoAreaMaxSize)],sizeof(DeviceSerialNumber)); } return sts; } int GT521FX::WaitPress(int press) { while(IsPress() != press); return 0; } int GT521FX::CmosLed(int onoff) { long Parameter = onoff & 1; short Response = 0; int sts = 0; sts = SendRecv(CMD_CmosLed,&Parameter,&Response); if((sts != 0) || (Response != CMD_Ack)) { return -1; } return 0; } int GT521FX::IsPress(void) { long Parameter = 0; short Response = 0; int sts = 0; sts = SendRecv(CMD_IsPressFinger,&Parameter,&Response); if((sts != 0) || (Response != CMD_Ack)) return 0; if(Parameter != 0) return 0; return 1; } int GT521FX::Capture(int best) { long Parameter = best; short Response = 0; int sts = 0; sts = SendRecv(CMD_CaptureFinger,&Parameter,&Response); if((sts != 0) || (Response != CMD_Ack)) return -1; return 0; } int GT521FX::Enroll_N(int N) { long Parameter = 0; short Response = 0; int sts = 0; enum Command cmd; switch(N) { default: case 1: cmd = CMD_Enroll1; break; case 2: cmd = CMD_Enroll2; break; case 3: cmd = CMD_Enroll3; break; } sts = SendRecv(cmd,&Parameter,&Response); if((sts != 0) || (Response != CMD_Ack)) return -1; return 0; } int GT521FX::Identify(void) { long Parameter = 0; short Response = 0; int sts = 0; sts = SendRecv(CMD_Identify,&Parameter,&Response); if((sts != 0) || (Response != CMD_Ack)) return -1; return Parameter; } int GT521FX::Enroll(int ID,int (*progress)(int status,char *msg)) { long Parameter = 0; short Response = 0; int sts = 0; CmosLed(1); while(1) { if((sts = (*progress)(1,"EnrollStart\n")) != 0) return -9999; Parameter = ID; sts = SendRecv(CMD_EnrollStart,&Parameter,&Response); if(sts != 0) return sts; if(Response != CMD_Ack) return -100; if((sts = (*progress)(0,"Remove finger\n")) != 0) return -9999; WaitPress(0); while(1) { if((sts = (*progress)(10,"Press finger to Enroll (1st)\n")) != 0) return -9999; WaitPress(1); if(Capture(1) == 0) break; } if((sts = (*progress)(0,"Remove finger\n")) != 0) return -9999; if(Enroll_N(1) != 0) continue; WaitPress(0); while(1) { if((sts = (*progress)(20,"Press finger to Enroll (2nd)\n")) != 0) return -9999; WaitPress(1); if(Capture(1) == 0) break; } if((sts = (*progress)(0,"Remove finger\n")) != 0) return -9999; if(Enroll_N(2) != 0) continue; WaitPress(0); while(1) { if((sts = (*progress)(30,"Press finger to Enroll (3rd)\n")) != 0) return -9999; WaitPress(1); if(Capture(1) == 0) break; } if((sts = (*progress)(0,"Remove finger\n")) != 0) return -9999; if(Enroll_N(3) != 0) continue; WaitPress(0); if((sts = (*progress)(100,"Enroll OK\n")) != 0) return -9999; break; } return 0; } int GT521FX::CheckEnrolled(int ID) { long Parameter = ID; short Response = 0; int sts = 0; sts = SendRecv(CMD_CheckEnrolled,&Parameter,&Response); if((sts == 0) && (Response == CMD_Ack)) return 0; //This ID is enrolled return -1; } int GT521FX::SetTemplate(int ID, char *data, long size) { long Parameter = ID; short Response = 0; int sts = 0; sts = SendRecv(CMD_SetTemplate,&Parameter,&Response); if ((sts != 0) || (Response != CMD_Ack)) return -1; sts = SendData(data, size); if (sts != 0) return -2; sts = RecvResponse(&Parameter, &Response); if ((sts != 0) || (Response != CMD_Ack)) return Response; // -3; return 0; } int GT521FX::DeleteID(int ID) { long Parameter = ID; short Response = 0; int sts = 0; sts = SendRecv(CMD_DeleteID,&Parameter,&Response); if((sts == 0) && (Response == CMD_Ack)) return 0; return -1; } int GT521FX::DeleteAllIDs() { long Parameter = 0; short Response = 0; int sts = 0; sts = SendRecv(CMD_DeleteAll,&Parameter,&Response); if((sts == 0) && (Response == CMD_Ack)) return 0; return -1; } int GT521FX::GetEnrollCount() { long Parameter = 0; short Response = 0; int sts = 0; sts = SendRecv(CMD_GetEnrollCount, &Parameter, &Response); if((sts != 0) || (Response != CMD_Ack)) return -1; return Parameter; }
#include <string> #include <cmath> #include <fstream> #include <iostream> #include <sstream> #include <list> #include <algorithm> #include <set> #include <map> #include <stack> #include <queue> #include <numeric> #include <bitset> #include <deque> //#include <random> #include <string.h> #include <stdlib.h> #include <vector> const long long LINF = (1e18); const int INF = (1<<28); const int sINF = (1<<23); const int MOD = 1000000007; const double EPS = 1e-6; using namespace std; class BuildingRoutes { public: int conv(char ch) { return ch - '0'; } int build(vector <string> dist, int T) { int N = (int)dist.size(); vector<vector<int> > mdist(N, vector<int>(N, INF)); for (int i=0; i<N; ++i) for (int j=0; j<N; ++j) mdist[i][j] = conv(dist[i][j]); for (int k=0; k<N; ++k) for (int i=0; i<N; ++i) for (int j=0; j<N; ++j) mdist[i][j] = min(mdist[i][j], mdist[i][k] + mdist[k][j]); vector<vector<int> > rcount(N, vector<int>(N, 0)); for (int a=0; a<N; ++a) for (int b=0; b<N; ++b) for (int x=0; x<N; ++x) for (int y=0; y<N; ++y) if ( (mdist[a][x] + conv(dist[x][y]) + mdist[y][b]) == mdist[a][b]) rcount[x][y]++; int ans = 0; for (int x=0; x<N; ++x) for (int y=0; y<N; ++y) if (rcount[x][y] >= T) ans += conv(dist[x][y]); return ans; } // BEGIN CUT HERE public: void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); } private: template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); } void verify_case(int Case, const int &Expected, const int &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } } void test_case_0() { string Arr0[] = {"011", "101", "110"}; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 1; int Arg2 = 6; verify_case(0, Arg2, build(Arg0, Arg1)); } void test_case_1() { string Arr0[] = {"033", "309", "390"}; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 1; int Arg2 = 12; verify_case(1, Arg2, build(Arg0, Arg1)); } void test_case_2() { string Arr0[] = {"0123", "1023", "1203", "1230"}; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 2; int Arg2 = 5; verify_case(2, Arg2, build(Arg0, Arg1)); } void test_case_3() { string Arr0[] = {"05789654", "10347583", "65085479", "55602398", "76590934", "57939045", "12345608", "68647640"}; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 3; int Arg2 = 40; verify_case(3, Arg2, build(Arg0, Arg1)); } // END CUT HERE }; // BEGIN CUT HERE int main() { BuildingRoutes ___test; ___test.run_test(-1); } // END CUT HERE
#ifndef _GREEN2_H #define _GREEN2_H #include "Enemy.h" #include "Path.h" class GREEN2 : public Enemy { private: iPoint original_pos; Path path; Animation fly; Animation forward; Animation backward; public: GREEN2(int x, int y, int type); void Move(); }; #endif
/*********************************************************************** cpp£º Lights Desc£ºdef of light interfaces and light description structure ************************************************************************/ #include "Noise3D.h" using namespace Noise3D; //-------------------Base Light-------------------------- void IBaseLight::SetAmbientColor(const NVECTOR3 & color) { mBaseLightDesc.ambientColor = Clamp(color, NVECTOR3(0.0f, 0.0f, 0.0f), NVECTOR3(1.0f, 1.0f, 1.0f)); } void IBaseLight::SetDiffuseColor(const NVECTOR3 & color) { mBaseLightDesc.diffuseColor = Clamp(color, NVECTOR3(0.0f, 0.0f, 0.0f), NVECTOR3(1.0f, 1.0f, 1.0f)); } void IBaseLight::SetSpecularColor(const NVECTOR3 & color) { mBaseLightDesc.specularColor = Clamp(color, NVECTOR3(0.0f, 0.0f, 0.0f), NVECTOR3(1.0f, 1.0f, 1.0f)); } void IBaseLight::SetSpecularIntensity(float specInt) { mBaseLightDesc.specularIntensity = Clamp(specInt, 0.0f, 100.0f); } void IBaseLight::SetDiffuseIntensity(float diffInt) { mBaseLightDesc.diffuseIntensity = Clamp(diffInt, 0.0f, 100.0f); } void IBaseLight::SetDesc(const N_CommonLightDesc & desc) { SetDiffuseColor(desc.diffuseColor); SetAmbientColor(desc.ambientColor); SetSpecularColor(desc.specularColor); SetSpecularIntensity(desc.specularIntensity); SetDiffuseIntensity(desc.diffuseIntensity); } void IBaseLight::GetDesc(N_CommonLightDesc & outDesc) { outDesc.ambientColor = mBaseLightDesc.ambientColor; outDesc.diffuseColor = mBaseLightDesc.diffuseColor; outDesc.specularColor = mBaseLightDesc.specularColor; outDesc.diffuseIntensity = mBaseLightDesc.diffuseIntensity; outDesc.specularIntensity = mBaseLightDesc.specularIntensity; } //--------------------DYNAMIC DIR LIGHT------------------ IDirLightD::IDirLightD() { ZeroMemory(this, sizeof(*this)); mLightDesc.specularIntensity = 1.0f; mLightDesc.direction = NVECTOR3(1.0f, 0, 0); mLightDesc.diffuseIntensity = 0.5; } IDirLightD::~IDirLightD() { } void IDirLightD::SetDirection(const NVECTOR3& dir) { //the length of directional vector must be greater than 0 if (!(dir.x == 0 && dir.y == 0 && dir.z == 0)) { mLightDesc.direction = dir; } } void IDirLightD::SetDesc(const N_DirLightDesc & desc) { IBaseLight::SetDesc(desc);//only modify the common part SetDirection(desc.direction);//modify extra part } N_DirLightDesc IDirLightD::GetDesc() { //fill in the common attribute part IBaseLight::GetDesc(mLightDesc); return mLightDesc; } //--------------------DYNAMIC POINT LIGHT------------------ IPointLightD::IPointLightD() { mLightDesc.specularIntensity = 1.0f; mLightDesc.mAttenuationFactor = 0.05f; mLightDesc.mLightingRange = 100.0f; mLightDesc.diffuseIntensity = 0.5; } IPointLightD::~IPointLightD() { } void IPointLightD::SetPosition(const NVECTOR3 & pos) { mLightDesc.mPosition = pos; } void IPointLightD::SetAttenuationFactor(float attFactor) { mLightDesc.mAttenuationFactor = Clamp(attFactor,0.0f,1.0f); } void IPointLightD::SetLightingRange(float range) { mLightDesc.mLightingRange = Clamp(range, 0.0f, 10000000.0f); } void IPointLightD::SetDesc(const N_PointLightDesc & desc) { IBaseLight::SetDesc(desc); SetPosition(desc.mPosition); SetAttenuationFactor(desc.mAttenuationFactor); SetLightingRange(desc.mLightingRange); } N_PointLightDesc IPointLightD::GetDesc() { //fill in the common attribute part IBaseLight::GetDesc(mLightDesc); return mLightDesc; } //--------------------DYNAMIC SPOT LIGHT------------------ ISpotLightD::ISpotLightD() { mLightDesc.specularIntensity = 1.0f; mLightDesc.mAttenuationFactor = 1.0f; mLightDesc.mLightingRange = 100.0f; mLightDesc.mLightingAngle = MATH_PI / 4; mLightDesc.diffuseIntensity = 0.5; mLightDesc.mLitAt = NVECTOR3(1.0f, 0, 0); mLightDesc.mPosition = NVECTOR3(0, 0, 0); } ISpotLightD::~ISpotLightD() { } void ISpotLightD::SetPosition(const NVECTOR3 & pos) { NVECTOR3 deltaVec = pos - mLightDesc.mLitAt; //pos and litAt can't superpose if (!(deltaVec.x == 0 && deltaVec.y == 0 && deltaVec.z == 0)) { mLightDesc.mPosition = pos; } } void ISpotLightD::SetAttenuationFactor(float attFactor) { mLightDesc.mAttenuationFactor = Clamp(attFactor,0.0f,1.0f); } void ISpotLightD::SetLitAt(const NVECTOR3 & vLitAt) { NVECTOR3 deltaVec = vLitAt - mLightDesc.mPosition; //pos and litAt can't superpose if (!(deltaVec.x == 0 && deltaVec.y == 0 && deltaVec.z == 0)) { mLightDesc.mLitAt = vLitAt; } } void ISpotLightD::SetLightingAngle(float coneAngle_Rad) { // i'm not sure...but spot light should have a cone angle smaller than ¦Ð...?? mLightDesc.mLightingAngle = Clamp(coneAngle_Rad, 0.0f, MATH_PI-0.001f); } void ISpotLightD::SetLightingRange(float range) { mLightDesc.mLightingRange = Clamp(range, 0.0f, 10000000.0f); } void ISpotLightD::SetDesc(const N_SpotLightDesc & desc) { IBaseLight::SetDesc(desc); SetPosition(desc.mPosition); SetLitAt(desc.mLitAt); SetAttenuationFactor(desc.mAttenuationFactor); SetLightingRange(desc.mLightingRange); SetLightingAngle(desc.mLightingAngle); } N_SpotLightDesc ISpotLightD::GetDesc() { //fill in the common attribute part IBaseLight::GetDesc(mLightDesc); return mLightDesc; } //--------------------STATIC DIR LIGHT------------------ N_DirLightDesc IDirLightS::GetDesc() { return mLightDesc; } IDirLightS::IDirLightS() { }; IDirLightS::~IDirLightS() { } bool IDirLightS::mFunction_Init(const N_DirLightDesc & desc) { mLightDesc.ambientColor = Clamp(desc.ambientColor, NVECTOR3(0.0f, 0.0f, 0.0f), NVECTOR3(1.0f, 1.0f, 1.0f)); mLightDesc.diffuseColor = Clamp(desc.diffuseColor, NVECTOR3(0.0f, 0.0f, 0.0f), NVECTOR3(1.0f, 1.0f, 1.0f)); mLightDesc.specularColor = Clamp(desc.specularColor, NVECTOR3(0.0f, 0.0f, 0.0f), NVECTOR3(1.0f, 1.0f, 1.0f)); mLightDesc.specularIntensity = Clamp(desc.specularIntensity, 0.0f, 100.0f); mLightDesc.diffuseIntensity = Clamp(desc.diffuseIntensity, 0.0f, 100.0f); //the length of directional vector must be greater than 0 const NVECTOR3& dir = desc.direction; if ((dir.x == 0 && dir.y == 0 && dir.z == 0)) { ERROR_MSG("Dir Light Init: direction can't be (0,0,0)"); return false; } else { mLightDesc.direction = dir; return true; } } //--------------------STATIC POINT LIGHT------------------ N_PointLightDesc IPointLightS::GetDesc() { return mLightDesc; }; IPointLightS::IPointLightS() { } IPointLightS::~IPointLightS() { } bool IPointLightS::mFunction_Init(const N_PointLightDesc & desc) { mLightDesc.ambientColor = Clamp(desc.ambientColor, NVECTOR3(0.0f, 0.0f, 0.0f), NVECTOR3(1.0f, 1.0f, 1.0f)); mLightDesc.diffuseColor = Clamp(desc.diffuseColor, NVECTOR3(0.0f, 0.0f, 0.0f), NVECTOR3(1.0f, 1.0f, 1.0f)); mLightDesc.specularColor = Clamp(desc.specularColor, NVECTOR3(0.0f, 0.0f, 0.0f), NVECTOR3(1.0f, 1.0f, 1.0f)); mLightDesc.specularIntensity = Clamp(desc.specularIntensity, 0.0f, 100.0f); mLightDesc.diffuseIntensity = Clamp(desc.diffuseIntensity, 0.0f, 100.0f); mLightDesc.mPosition = desc.mPosition; mLightDesc.mAttenuationFactor = Clamp(desc.mAttenuationFactor, 0.0f, 1.0f); mLightDesc.mLightingRange = Clamp(desc.mAttenuationFactor, 0.0f, 10000000.0f); return true; } //--------------------STATIC SPOT LIGHT------------------ N_SpotLightDesc ISpotLightS::GetDesc() { return mLightDesc; } ISpotLightS::ISpotLightS() { } ISpotLightS::~ISpotLightS() { } bool ISpotLightS::mFunction_Init(const N_SpotLightDesc & desc) { mLightDesc.ambientColor = Clamp(desc.ambientColor, NVECTOR3(0.0f, 0.0f, 0.0f), NVECTOR3(1.0f, 1.0f, 1.0f)); mLightDesc.diffuseColor = Clamp(desc.diffuseColor, NVECTOR3(0.0f, 0.0f, 0.0f), NVECTOR3(1.0f, 1.0f, 1.0f)); mLightDesc.specularColor = Clamp(desc.specularColor, NVECTOR3(0.0f, 0.0f, 0.0f), NVECTOR3(1.0f, 1.0f, 1.0f)); mLightDesc.specularIntensity = Clamp(desc.specularIntensity, 0.0f, 100.0f); mLightDesc.diffuseIntensity = Clamp(desc.diffuseIntensity, 0.0f, 100.0f); mLightDesc.mPosition = desc.mPosition; mLightDesc.mAttenuationFactor = Clamp(desc.mAttenuationFactor, 0.0f, 1.0f); mLightDesc.mLightingRange = Clamp(desc.mAttenuationFactor, 0.0f, 10000000.0f); //pos and litAt can't superpose NVECTOR3 deltaVec = desc.mLitAt - desc.mPosition; if (!(deltaVec.x == 0 && deltaVec.y == 0 && deltaVec.z == 0)) { mLightDesc.mLitAt = desc.mLitAt; } else { ERROR_MSG("Spot Light Init: pos and LitAt can't be the same."); return false; } // i'm not sure...but spot light should have a cone angle smaller than ¦Ð...?? mLightDesc.mLightingAngle = Clamp(desc.mLightingAngle, 0.0f, MATH_PI - 0.001f); return true; }
#include<iostream> #include<string> #include<algorithm> using namespace std; int main() { int i, c = 0; string s; cin >> s; sort(s.begin(), s.end()); for (i = 0; i < s.length(); i++) { if (s[i] != s[i + 1]) { c++; } } if (c % 2 == 0) { cout << "CHAT WITH HER!"; } else { cout << "IGNORE HIM!"; } return 0; }
#ifndef MAPBOARD_H #define MAPBOARD_H #include <string> //#include "serverdaemon.cpp" struct mapboard { int rows;//8 int cols;//8 pid_t daemonID; //processid of daemon pid_t players[5]; unsigned char map[0]; //0 }; //sem_t *sem; // semaphore void create_server_daemon(); void create_client_daemon(std::string ipaddr); #endif
#include "Pixel.h" #include <iostream> using namespace std; // Constructeur par défaut de la classe: initialise le pixel à la couleur noire Pixel::Pixel() { r = 0; g = 0; b = 0; } // Constructeur de la classe: initialise r,g,b avec les paramètres Pixel::Pixel (const unsigned char nr,const unsigned char ng,const unsigned char nb) { r = nr; g = ng; b = nb; } // Accesseur : récupère la composante rouge du pixel unsigned char Pixel::getRouge () const { return r; } // Accesseur : récupère la composante verte du pixel unsigned char Pixel::getVert () const { return g; } // Accesseur : récupère la composante bleue du pixel unsigned char Pixel::getBleu () const { return b; } // Mutateur : modifie la composante rouge du pixel void Pixel::setRouge (const unsigned char sr) { r = sr; } // Mutateur : modifie la composante verte du pixel void Pixel::setVert (const unsigned char sg) { g = sg; } // Mutateur : modifie la composante bleue du pixel void Pixel::setBleu (const unsigned char sb) { b = sb; }
#include "../../Point2D.h" #include <iostream> #include <cmath> #include <cassert> #define test_point(pt, X, Y) assert(fabs(pt.x() - X) < 0.0001 && fabs(pt.y() - Y) < 0.0001); int main(void) { Point2D pt; test_point(pt, 0.f, 0.f); std::cout << 1 << std::endl; pt.x(1.f); pt.y(2.f); test_point(pt, 1.f, 2.f); std::cout << 2 << std::endl; pt.x() = 3.f; pt.y() = 4.f; test_point(pt, 3.f, 4.f); std::cout << 3 << std::endl; pt[0] = 5.f; pt[1] = 6.f; test_point(pt, 5.f, 6.f); std::cout << 4 << std::endl; assert(pt[0] == pt.x()); assert(pt[1] == pt.y()); return 0; }
#include <Arduino.h> #include "HBridgeMotor.h" class HBridge_Controller { private: HBridge_Motor motor0; HBridge_Motor motor1; public: HBridge_Controller(); HBridge_Controller(HBridge_Motor m0, HBridge_Motor m1); void setEnable(uint8_t enA, uint8_t enB); void stop(); void forwards(); void backwards(); };
#include "processflow_app.h" #include <QDir> #include <QMessageBox> #include <algorithm> #include "qt-tools/common.hpp" #include "json.hpp" APP_REGISTER (processflow_app) using namespace std; using json = nlohmann::json; processflow_app::processflow_app(int argc, char ** argv) : application(argc, argv) { if (argc < 2) { go [this] { update_check(); }; } } bool processflow_app::run() { main_ = sheetflow_main::make(); main_->show(); return true; } void processflow_app::exec_update(std::vector<std::pair<std::string, std::string>> file_info) { Q_UNUSED(file_info) if (QMessageBox::question (nullptr, "自动更新", "发现新版本,是否更新","是","否") == 1) { return; } auto json_file_info = json::array (); for (auto & it : file_info) { json_file_info.push_back ({{"path", it.first}, {"md5", it.second}}); } json json_param { {"prefix", UPDATE_FILE_PATH}, {"files", ::move (json_file_info)}, {"exec", EXEC_FILE}, {"server_addr", SERVER_ADDR} }; auto parameter = binary_to_base64 (json_param.dump ()); ::system(("start "s + UPDATE_PATH + " " + parameter).data ()); processflow_app::exit (0); } void processflow_app::update_check() { auto files = ::check_for_update (SERVER_ADDR, "/schedule/update", SOFTWARE_NAME); if (files.empty ()) { return; } call_after [this, files = ::move (files)] () mutable { this->exec_update (::move (files)); }; }
// #include <boost/multiprecision/cpp_int.hpp> // using boost::multiprecision::cpp_int; #include <bits/stdc++.h> using namespace std; #define f first #define s second #define mp make_pair #define pb push_back #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define debug(x) cout << '>' << #x << ':' << x << endl; #define all(v) v.begin(), v.end() #define sz(x) ((int)(x).size()) #define endl " \n" #define newl cout<<"\n" #define MAXN 100005 //#define MOD 1000000007LL #define EPS 1e-13 #define INFI 1000000000 // 10^9 #define INFLL 1000000000000000000ll //10^18 #define ll long long int #define ull unsigned long long int #define ld long double #define vll vector<long long> #define vvll vector<vll> #define pll pair<long long, long long> #define fast_io() \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); ll tc, n, m, k; //Also there is a formula for prefix xors 0 ^ 1 ^ .... ^ k: int xorUpToK(int k) { switch (k % 4) { case 0: return k; case 1: return 1; case 2: return k + 1; case 3: return 0; } } int main() { fast_io(); #ifndef ONLINE_JUDGE freopen("../input.txt", "r", stdin); freopen("../output.txt", "w", stdout); #endif //https://codeforces.com/contest/424/problem/C cin>>n; vll arr(n, 0); rep(i, 0, n) cin>>arr[i]; vll pre(n+1, 0); pre[0] = 0; rep(i, 1, n+1) { pre[i] = pre[i-1]^i; } ll ans = 0; rep(i, 1, n+1) { ans ^= arr[i-1]; ll times = n/i; ll rem = n - i*times; if(times%2) { ans ^= (pre[i-1]^pre[rem]); } else { ans ^= (pre[rem]); } } cout<<ans;; return 0; }
#include "getthresholdvalue.h" #include "opencv2/opencv.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #include <QDialog> #include <QDebug> #include <QMessageBox> #include"dialrecognition.h" using namespace cv; int threshold_value = 0; int threshold_type = 1; int const max_value = 255; int const max_type = 4; int const max_BINARY_value = 255; Mat src, src_gray, dst; const char* window_name ="阈值查看器"; const char* trackbar_type = "Type: \n 0: Binary \n 1: Binary Inverted \n 2: Truncate \n 3: To Zero \n 4: To Zero Inverted"; //const char* trackbar_type = "Type: \n 0: Binary ; 1: Binary Inverted ; \n 2: Truncate ; 3: To Zero ; 4: To Zero Inverted"; const char* trackbar_value = "Value"; void Threshold_Demo( int, void* ); getthresholdvalue::getthresholdvalue(QWidget *parent): QDialog(parent) { qDebug()<<filename; QPixmap test; if(!test.load("pic/graydpic.jpg")) { QMessageBox::warning(0,QString::fromLocal8Bit("图片打开失败"),QString::fromLocal8Bit("图片不存在或路径有误")); } else if(filename=="") { QMessageBox::information(0,QString::fromLocal8Bit("提醒"),QString::fromLocal8Bit("请导入原图片")); } else { src = imread( "pic/graydpic.jpg" ); // Load an image cv::resize(src,src,Size(600,450),0,0,INTER_LINEAR); cvtColor( src, src_gray, COLOR_BGR2GRAY ); // Convert the image to Gray namedWindow( window_name, WINDOW_AUTOSIZE ); // Create a window to display results Threshold_Demo( 0, 0 ); createTrackbar( trackbar_type, window_name, &threshold_type, max_type, Threshold_Demo ); // Create Trackbar to choose type of Threshold createTrackbar( trackbar_value, window_name, &threshold_value, max_value, Threshold_Demo ); // Create Trackbar to choose Threshold value // Threshold_Demo( 0, 0 ); // Call the function to initialize for(;;) { char c = (char)waitKey( 20 ); if( c == 27 ) { break; } } waitKey(0); } } void Threshold_Demo( int, void* ) { /* 0: Binary 1: Binary Inverted 2: Threshold Truncated 3: Threshold to Zero 4: Threshold to Zero Inverted */ threshold( src_gray, dst, threshold_value, max_BINARY_value,threshold_type ); imshow( window_name, dst ); }
#include <sstream> #include "speech.hh" SpeechTab *SpeechTab::SpeechTab_ = 0; string SpeechTab::speechText = "Not Initialized"; GtkWidget *SpeechTab::speech_edit = 0; GtkWidget *SpeechTab::button_speech = 0; string SpeechTab::speech_lang_ = "fr"; //send speech record to iSpeak_all void send_speech (history_record *h) { //create bottle Bottle bot; //add command to bottle string s = h->command; bot.addString(s.c_str()); //send command to iSpeak_all outportSpeak_.write(bot); //save record on history saveToHistory("Speech", h->name, 0, h->command); } //send command to iPeak_all from interactive entry void button_speech_click(GtkWidget *widget) { //get entry data SpeechTab::speechText = gtk_entry_get_text(GTK_ENTRY(SpeechTab::speech_edit)); //create history record history_record h; std::stringstream stream(SpeechTab::speechText); stream >> h.name; // add langauge setting to command (fr || en) h.command = SpeechTab::speech_lang_ + " '" + SpeechTab::speechText + "'"; //send command send_speech (&h); } //send command to isSPeak_all from pre recorded sentences void ExampleButton_speech_click(GtkWidget *widget) { //get entry snetences SpeechTab::speechText = gtk_button_get_label(GTK_BUTTON(widget)); //create history history_record h; std::stringstream stream(SpeechTab::speechText); stream >> h.name; // add language setting to command (en || fr) h.command = SpeechTab::speech_lang_ + " '" + SpeechTab::speechText + "'"; send_speech (&h); } //Switch between language setting void set_speech_lang (GtkWidget *w, gpointer lang) { //get current language gpointer label = g_object_get_data (G_OBJECT(w), "label"); SpeechTab::speech_lang_ = (const char*) lang; //change language string s = SpeechTab::speech_lang_; if (s == "fr") gtk_label_set_text (GTK_LABEL(label), "French"); if (s == "en") gtk_label_set_text (GTK_LABEL(label), "English"); //add info about setting infoTab::instance()->add_info ("Set language: " + SpeechTab::speech_lang_); } void SpeechTab::createSpeechTab (GtkWidget *notebook) { GtkWidget *speechTab; GtkWidget *speechFixed; GtkWidget *speechLabel = gtk_label_new("Speech"); speechTab = gtk_frame_new ("What i say"); gtk_container_set_border_width (GTK_CONTAINER (speechTab), 10); gtk_notebook_append_page (GTK_NOTEBOOK(notebook), speechTab, speechLabel); //---- intercative speech (manual entry) speechFixed = gtk_fixed_new (); GtkWidget *interactiveSpeechFixed = gtk_fixed_new (); gtk_container_add (GTK_CONTAINER(speechTab), speechFixed); gtk_fixed_put(GTK_FIXED(speechFixed), interactiveSpeechFixed, 400, 0); // the entry for the speech text speech_edit = gtk_entry_new (); gtk_entry_set_editable(GTK_ENTRY(speech_edit),true); gtk_entry_set_text(GTK_ENTRY(speech_edit), "Hello"); gtk_widget_set_size_request(speech_edit, 282, 35); // the button to validate button_speech = gtk_button_new_with_label("Say this!"); gtk_widget_set_size_request(button_speech, 100, 35); g_signal_connect(G_OBJECT(button_speech), "clicked", G_CALLBACK(button_speech_click), NULL); //--- LANGUAGE GtkWidget *languageFrame = gtk_frame_new ("Language"); gtk_widget_set_size_request(languageFrame, 400, 200); gtk_fixed_put(GTK_FIXED(interactiveSpeechFixed), languageFrame, 0, 150); GtkWidget *langTable = gtk_table_new (4, 2, true); gtk_container_add(GTK_CONTAINER(languageFrame), langTable); GtkWidget *currentLangLabel2 = gtk_label_new("French"); gtk_table_attach_defaults (GTK_TABLE (langTable), currentLangLabel2, 1, 2, 0, 1); GtkWidget *currentLangLabel1 = gtk_label_new("Current language: "); gtk_table_attach_defaults (GTK_TABLE (langTable), currentLangLabel1, 0, 1, 0, 1); GtkWidget *setCurrentLangLabel = gtk_label_new("Set Language: "); gtk_table_attach_defaults (GTK_TABLE (langTable), setCurrentLangLabel, 0, 2, 1, 2); // the button change to french GtkWidget *button_set_french = gtk_button_new_with_label("French"); gtk_widget_set_size_request(button_set_french, 100, 35); g_signal_connect(G_OBJECT(button_set_french), "clicked", G_CALLBACK(set_speech_lang), (gpointer) "fr"); gtk_table_attach_defaults (GTK_TABLE (langTable), button_set_french, 0, 1, 2, 3); g_object_set_data (G_OBJECT(button_set_french), "label", (gpointer) currentLangLabel2); // the button to change to english GtkWidget *button_set_english = gtk_button_new_with_label("English"); gtk_widget_set_size_request(button_set_english, 100, 35); g_signal_connect(G_OBJECT(button_set_english), "clicked", G_CALLBACK(set_speech_lang), (gpointer) "en"); gtk_table_attach_defaults (GTK_TABLE (langTable), button_set_english, 1, 2, 2, 3); g_object_set_data (G_OBJECT(button_set_english), "label", (gpointer) currentLangLabel2); gtk_fixed_put(GTK_FIXED(interactiveSpeechFixed), speech_edit, 6, 6); gtk_fixed_put(GTK_FIXED(interactiveSpeechFixed), button_speech, 100, 44); GtkWidget *scrolledwindow = gtk_scrolled_window_new(NULL, NULL); gtk_container_add(GTK_CONTAINER(speechFixed), scrolledwindow); GtkWidget *speechExampleFixed; //---- example entry from conf file GtkWidget *speechExampleButton; speechExampleFixed = gtk_fixed_new (); gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(scrolledwindow), speechExampleFixed); gtk_widget_set_size_request (scrolledwindow, 300, 600); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_show (scrolledwindow); std::vector<string> *speechExampleList = new std::vector<string> (); if (RFspeechConf_.check("Example")) { Bottle &grp = RFspeechConf_.findGroup("Example"); for (int i = 0; i < grp.size() - 1; i++){ char buff[100]; sprintf (buff , "%d", i); speechExampleList->push_back (grp.find(buff).asString().c_str()); } for (unsigned int i = 0; i < speechExampleList->size (); i++) { speechExampleButton = gtk_button_new_with_label (speechExampleList->at (i).c_str ()); gtk_widget_set_size_request(speechExampleButton, 282, 35); gtk_fixed_put(GTK_FIXED(speechExampleFixed), speechExampleButton, 0, 35 * i); gtk_widget_show (speechExampleButton); g_signal_connect(G_OBJECT(speechExampleButton), "clicked", G_CALLBACK(ExampleButton_speech_click), NULL); } } gtk_widget_show (speechLabel); } //get the instance of the singleton SpeechTab SpeechTab *SpeechTab::instance () { if (SpeechTab_) return (SpeechTab_); else { SpeechTab::SpeechTab_ = new SpeechTab (); return (SpeechTab::SpeechTab_); } }
#include <iostream> using namespace std; int main() { int N, S; cin >> N >> S; --S; int a[N], b[N]; for (int i = 0; i < N; ++i) cin >> a[i]; for (int i = 0; i < N; ++i) cin >> b[i]; if (a[0] && a[S]) { cout << "YES" << endl; return 0; } for (int k = S + 1; k < N; ++k) { if (a[0] && a[k] && b[k] && b[S]) { cout << "YES" << endl; return 0; } } cout << "NO" << endl; return 0; }
#include <iostream> #include <map> #include <unordered_map> #include <queue> #include <vector> #include <string> #include <utility> using namespace std; unordered_map<string, int> nameMap; // map<string, int> nameMap; struct BagDependency { int bagIdx, bagCount; //BagDependency(); }; struct Node { vector<BagDependency> bags; int outCount; int inCount; Node(int inCount, int outCount) : outCount(outCount), inCount(inCount), bags(vector<BagDependency>()) {} Node() : bags(vector<BagDependency>()), outCount(0), inCount(0) {} }; vector<Node> vertex; int main(){ //vertex.resize(1000); int nodeIdx = 0, lineIdx = 0; vector<string> input; // vector<vector<BagDependency> > bagDep; string line; const char separator[] = " bags contain "; while(getline(cin, line)){ input.push_back(line); size_t pos = line.find(separator); if(pos == string::npos){ cout << "Line: " << lineIdx << "Error: \"contain \" not found" << endl; exit(-1); } int fromIdx = nodeIdx; string key = line.substr(0, pos); nameMap[key] = fromIdx; nodeIdx++; //int bagCount; int count = 0; for(size_t newPos = line.find(", ", pos); ((newPos = line.find(", ", pos)) != string::npos) || ((newPos = line.find(".", pos)) != string::npos); pos = newPos+2){ count++; } vertex.push_back(Node(0, count)); /* } */ } for(int i = 0; i < vertex.size(); i++){ size_t pos = input[i].find(separator)+sizeof(separator)-1; if(input[i].find("bags contain no other bags.") != string::npos){ continue; } for(size_t newPos = input[i].find(", ", pos); ((newPos = input[i].find(", ", pos)) != string::npos) || ((newPos = input[i].find(".", pos)) != string::npos); pos = newPos+2){ string depStr = input[i].substr(pos, newPos-pos); size_t intEnd = depStr.find(" "); int bagCount = atoi(depStr.substr(0, intEnd).c_str()); size_t nameEnd = depStr.find(" bag"); string bagName = depStr.substr(intEnd+1, nameEnd-(intEnd+1)); // cout << bagName << " " << bagCount << endl; int bagIdx = nameMap[bagName]; vertex[i].bags.push_back({.bagIdx=bagIdx, .bagCount=bagCount}); vertex[bagIdx].inCount++; //vertex[i].outCount++; } } for(int i = 0; i < vertex.size(); i++){ cout << i << ": in " << vertex[i].inCount << " out " << vertex[i].outCount << ":"; for(auto b : vertex[i].bags){ cout << " " << b.bagIdx << " (" << b.bagCount << ")"; } cout << endl; } /* for(const auto& it : nameMap){ cout << it.first << " " << it.second << endl; } */ //queue<int> q; // Generate reversed edge DAG vector<Node> rev(vertex.size()); for(int i = 0; i < vertex.size(); i++){ for( auto b : vertex[i].bags ){ rev[b.bagIdx].bags.push_back({.bagIdx=i, .bagCount=0}); rev[b.bagIdx].inCount = vertex[b.bagIdx].outCount; } } for(int i = 0; i < rev.size(); i++){ cout << i << ": in " << rev[i].inCount << " out " << rev[i].bags.size() << ":"; for(auto b : rev[i].bags){ cout << " " << b.bagIdx << " (" << b.bagCount << ")"; } cout << endl; } // BFS the reversed DAG queue<int> order; map<int, bool> seen; int root = nameMap["shiny gold"]; order.push(root); for(int cur = root;!order.empty();){ for(auto b : rev[cur].bags){ if(!seen[b.bagIdx]){ cout << b.bagIdx << endl; order.push(b.bagIdx); } } seen[cur] = true; cur = order.front(); order.pop(); } seen.erase(root); unordered_map<int, string> revMap; for(auto nm : nameMap){ revMap[nm.second] = nm.first; } for(auto s : seen){ cout << s.first << " " << revMap[s.first] << endl; } cout << seen.size() << endl; return 0; }
/* Question => GIven two 2D arrays of size n1 x n2 and n2 x n3. Your task is to multiply these matrics and output the multiplied matrix. Approach 1. Make a nested loop of order 3. In the outer loop iterate over rows of first matrix and in the inner loop iterate over columns of second matrix. 2. Multiply rows of first matrix with columns of second matrix in the innermost loop and update in the answer matrix. */ #include<iostream> using namespace std; int main(){ int n1, n2, n3; cout<<"Enter the value of n1: "; cin>>n1; cout<<"Enter the value of n2: "; cin>>n2; cout<<"Enter the value of n3: "; cin>>n3; int m1[n1][n2]; int m2[n2][n3]; for(int i=0; i<n1; i++){ for(int j=0; j<n2; j++){ cout<<"Enter the element in 1st matrix: "; cin>>m1[n1][n2]; } } for(int i=0; i<n2; i++){ for(int j=0; j<n3; j++){ cout<<"Enter the element in 2nd matrix: "; cin>>m2[n2][n3]; } } // Initializing the answer matrix with 0 int ans[n1][n3]; for(int i=0; i<n1; i++){ for(int j=0; j<n3; j++){ ans[i][j] = 0; } } // Multiplication for(int i=0; i<n1; i++){ for(int j=0; j<n3; j++){ for(int k=0; k<n2; k++){ ans[i][j] += m1[i][k] * m2[k][j]; } } } // Printing the results for(int i=0; i<n1; i++){ for(int j=0; j<n3; j++){ cout<<ans[i][j]<<" "; }cout<<"\n"; } }
#pragma once #include <iostream> #include <random> #include <string> #include <ctime> #include <algorithm> #include "UnionFind.h" #include "Maze.h" using namespace std; int main() { int width; int height; srand(time(nullptr)); cout << "width"; cin >> width; cout << "height"; cin >> height; unique_ptr<Maze> maze = make_unique<Maze>(width, height); maze->Generate(); maze->Display(); }
#pragma once template <typename C, typename S> long BinarySearch(C &container, S searchVal, long containerSize) { long min = 0; long max = containerSize - 1; long retVal = -1; while (true) { long target = (max + min) / 2; if (min > max) { break; } else if (container[target] == searchVal) { retVal = target; break; } else if (container[target] < searchVal) { min = target + 1; continue; } else if (container[target] > searchVal) { max = target - 1; continue; } else { break; } } return retVal; }
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int maxn = 100000+100, maxm = 1000000+100, maxq = 100000+100; int n, m, q; struct edge{ int s, t, c, num; bool useless ; edge(){} edge(int _s, int _t, int _c) : s(_s), t(_t) , c(_c), useless(false) {} } E[maxm]; int tot =0; bool cmp0(const edge & a, const edge & b) { return a.s < b.s || (a.s == b.s && a.t < b.t); } bool cmp1(const edge & a, const edge & b) { return a.c < b.c ; } struct query{ int k, x, y, delEdgeNumber; query(){} query(int _k, int _x, int _y) : k(_k) , x(_x), y(_y) {} } Q[maxq]; namespace unionSet{ int f[maxn]; int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); } void join (int x, int y) {f[find(x)] = find(y);} void init() { for(int i=1; i<=n; i++) f[i]=i; } }; namespace linkCutTree{ struct treeNode { treeNode * c[2], * p, * pos; int val, mx, num; bool rev ; treeNode() {} treeNode(int _v, int _num) : val(_v), mx(_v), num(_num), rev(0) {pos=this, c[0]=c[1]=p=NULL; } inline bool isRoot() {return p==NULL || (p->c[1]!=this && p->c[0]!=this) ; } inline bool d() {return p->c[1]==this;} inline void setChild(treeNode *n, bool d) { c[d]=n, c[d]->p=this; } inline void pushDown() { if (!rev) return ; else rev = 0; if (c[0]) c[0]->rev ^= 1; if (c[1]) c[1]->rev ^= 1; swap(c[0], c[1]); } inline void pushUp(){ mx = val, pos = this; if (c[0] && c[0]->mx > mx) mx=c[0]->mx, pos = c[0]->pos; if (c[1] && c[1]->mx > mx) mx=c[1]->mx, pos = c[1]->pos; } } pool[maxm+maxn] , *poolPos=pool, *node[maxn<<1|1]; inline void rotate(treeNode *o) { treeNode * p = o->p, *g = p->p; if(g) g->pushDown(); p->pushDown(); o->pushDown(); bool d=o->d(); if(!p->isRoot()) g->setChild(o, p->d()); else o->p=g; if(o->c[!d]) p->setChild(o->c[!d], d); else p->c[d]=NULL; o->setChild(p, !d); p->pushUp(); } inline void splay(treeNode *o) { while(!o->isRoot()) { if(o->p->isRoot()) rotate(o); else { if(o->p->d()==o->d()) rotate(o->p), rotate(o); else rotate(o), rotate(o); } } o->pushDown(); o->pushUp(); } inline void access(treeNode *o){ for(treeNode *p=NULL; o; o=o->p) { splay(o); o->c[1] = p; (p=o)->pushUp(); } } inline void makeRoot(treeNode *o) { access(o); splay(o); o->rev^=1;} inline void link(treeNode *x, treeNode *y) {makeRoot(x); x->p=y; } inline void cut(treeNode *x, treeNode *y) { access(y); splay(x); if (x->p == y) { if(y->c[1]==x) y->c[1]=NULL; else if(y->c[0]==x) y->c[0]=NULL; x->p=NULL; } else { access(x); splay(y); if(x->c[1]==y) x->c[1]=NULL; else if(x->c[0]==y) x->c[0]=NULL; y->p=NULL; } } inline treeNode * query(treeNode *x , treeNode *y){ treeNode * ret= NULL; for(access(y), y=NULL; x; y=x, x=x->p) { splay(x); if (x->p == NULL) { if (x->c[1] && (!ret || ret->mx < x->c[1]->mx)) ret=x->c[1]->pos; if (y && (!ret || ret->mx < y->mx)) ret=y->pos; } x->c[1] = y; x->pushUp(); } return ret; } inline void insertEdge(int num) { treeNode *x = node[E[num].s], *y = node[E[num].t], * r ; r=query(x,y); if (r->val <= E[num].c ) return ; cut(r, node[E[r->num].s]), cut(r, node[E[r->num].t]); r= new (poolPos++) treeNode(E[num].c, num); link(r, x), link(r, y); } }; #define SIZE 33000000 char inbuf[SIZE], *ip = inbuf; inline int getint() { int r = 0; while (*ip < '0' || *ip > '9') ++ip; while (*ip >= '0' && *ip <= '9') r = r * 10 + *(ip++) - '0'; return r; } namespace solver{ void readData(){ n=getint(), m=getint(), q=getint(); for(int i=1; i<=m; i++) { int s=getint(), t=getint(), c=getint(); if(s<t) E[i] = edge( s, t, c); else E[i]= edge(t, s, c); } sort(E+1, E+m+1, cmp0); for(int i=1; i<=m; i++) E[i].num=i; for(int i=1; i<=q; i++) { int k=getint(), x=getint(), y=getint(); if (x<y) Q[i] = query(k, x, y ); else Q[i] = query(k, y, x); if (Q[i].k==2) { int pos = lower_bound(E+1, E+m+1, edge(Q[i].x, Q[i].y, 0), cmp0)-E; E[pos].useless = true; Q[i].delEdgeNumber = pos; } } } void preTreatment() { int tot = m; for(int i=1; i<=tot; i++) if (E[i].useless) swap(E[i--], E[tot--]); sort(E+1, E+tot+1, cmp1); for(int i=1; i<=n; i++) linkCutTree::node[i]=new (linkCutTree::poolPos++) linkCutTree::treeNode (); unionSet::init(); for(int i=1, vecCnt=n; i<=tot; i++) { if(unionSet::find(E[i].s) != unionSet::find(E[i].t)) { unionSet::join(E[i].s, E[i].t); linkCutTree::node[++vecCnt]= new (linkCutTree::poolPos++) linkCutTree::treeNode (E[i].c, E[i].num); linkCutTree::link( linkCutTree::node[E[i].s], linkCutTree::node[vecCnt]); linkCutTree::link( linkCutTree::node[vecCnt], linkCutTree::node[E[i].t]); } } sort(E+1, E+m+1, cmp0); } int ans[maxq]; void work(){ for(int i=q; i>=1; i--) if (Q[i].k == 2) linkCutTree::insertEdge(Q[i].delEdgeNumber); else ans[i]=linkCutTree::query(linkCutTree::node[Q[i].x], linkCutTree::node[Q[i].y])->mx; for(int i=1; i<=q; i++) if (Q[i].k == 1) printf("%d\n", ans[i]); } }; int main(){ #ifndef ONLINE_JUDGE freopen("tube1.in","r",stdin); //freopen("tube1.out","w",stdout); #endif fread(inbuf, sizeof(char), sizeof(char) * SIZE, stdin); solver::readData(); solver::preTreatment(); solver::work(); return 0; }
#ifndef __VIVADO_SYNTH__ #include <fstream> using namespace std; // Debug utility ofstream* global_debug_handle; #endif //__VIVADO_SYNTH__ #include "mp_16_opt_compute_units.h" #include "hw_classes.h" struct in_in_update_0_write0_merged_banks_2_cache { // RAM Box: {[0, 112], [0, 127], [0, 31]} // Capacity: 9 // # of read delays: 2 hw_uint<32> f0; fifo<hw_uint<32> , 7> f1; hw_uint<32> f2; inline hw_uint<32> peek_0() { return f0; } inline hw_uint<32> peek_7() { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ return f1.back(); } inline hw_uint<32> peek_8() { return f2; } inline void push(const hw_uint<32> value) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 1 reading from capacity: 7 f2 = f1.back(); #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 7 reading from capacity: 1 f1.push(f0); // cap: 1 f0 = value; } }; struct in_in_update_0_write1_merged_banks_2_cache { // RAM Box: {[1, 113], [0, 127], [0, 31]} // Capacity: 9 // # of read delays: 2 hw_uint<32> f0; fifo<hw_uint<32> , 7> f1; hw_uint<32> f2; inline hw_uint<32> peek_0() { return f0; } inline hw_uint<32> peek_7() { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ return f1.back(); } inline hw_uint<32> peek_8() { return f2; } inline void push(const hw_uint<32> value) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 1 reading from capacity: 7 f2 = f1.back(); #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 7 reading from capacity: 1 f1.push(f0); // cap: 1 f0 = value; } }; struct in_in_update_0_write10_merged_banks_2_cache { // RAM Box: {[10, 122], [0, 127], [0, 31]} // Capacity: 9 // # of read delays: 2 hw_uint<32> f0; fifo<hw_uint<32> , 7> f1; hw_uint<32> f2; inline hw_uint<32> peek_0() { return f0; } inline hw_uint<32> peek_7() { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ return f1.back(); } inline hw_uint<32> peek_8() { return f2; } inline void push(const hw_uint<32> value) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 1 reading from capacity: 7 f2 = f1.back(); #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 7 reading from capacity: 1 f1.push(f0); // cap: 1 f0 = value; } }; struct in_in_update_0_write11_merged_banks_2_cache { // RAM Box: {[11, 123], [0, 127], [0, 31]} // Capacity: 9 // # of read delays: 2 hw_uint<32> f0; fifo<hw_uint<32> , 7> f1; hw_uint<32> f2; inline hw_uint<32> peek_0() { return f0; } inline hw_uint<32> peek_7() { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ return f1.back(); } inline hw_uint<32> peek_8() { return f2; } inline void push(const hw_uint<32> value) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 1 reading from capacity: 7 f2 = f1.back(); #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 7 reading from capacity: 1 f1.push(f0); // cap: 1 f0 = value; } }; struct in_in_update_0_write12_merged_banks_2_cache { // RAM Box: {[12, 124], [0, 127], [0, 31]} // Capacity: 9 // # of read delays: 2 hw_uint<32> f0; fifo<hw_uint<32> , 7> f1; hw_uint<32> f2; inline hw_uint<32> peek_0() { return f0; } inline hw_uint<32> peek_7() { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ return f1.back(); } inline hw_uint<32> peek_8() { return f2; } inline void push(const hw_uint<32> value) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 1 reading from capacity: 7 f2 = f1.back(); #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 7 reading from capacity: 1 f1.push(f0); // cap: 1 f0 = value; } }; struct in_in_update_0_write13_merged_banks_2_cache { // RAM Box: {[13, 125], [0, 127], [0, 31]} // Capacity: 9 // # of read delays: 2 hw_uint<32> f0; fifo<hw_uint<32> , 7> f1; hw_uint<32> f2; inline hw_uint<32> peek_0() { return f0; } inline hw_uint<32> peek_7() { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ return f1.back(); } inline hw_uint<32> peek_8() { return f2; } inline void push(const hw_uint<32> value) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 1 reading from capacity: 7 f2 = f1.back(); #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 7 reading from capacity: 1 f1.push(f0); // cap: 1 f0 = value; } }; struct in_in_update_0_write14_merged_banks_2_cache { // RAM Box: {[14, 126], [0, 127], [0, 31]} // Capacity: 9 // # of read delays: 2 hw_uint<32> f0; fifo<hw_uint<32> , 7> f1; hw_uint<32> f2; inline hw_uint<32> peek_0() { return f0; } inline hw_uint<32> peek_7() { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ return f1.back(); } inline hw_uint<32> peek_8() { return f2; } inline void push(const hw_uint<32> value) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 1 reading from capacity: 7 f2 = f1.back(); #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 7 reading from capacity: 1 f1.push(f0); // cap: 1 f0 = value; } }; struct in_in_update_0_write15_merged_banks_2_cache { // RAM Box: {[15, 127], [0, 127], [0, 31]} // Capacity: 9 // # of read delays: 2 hw_uint<32> f0; fifo<hw_uint<32> , 7> f1; hw_uint<32> f2; inline hw_uint<32> peek_0() { return f0; } inline hw_uint<32> peek_7() { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ return f1.back(); } inline hw_uint<32> peek_8() { return f2; } inline void push(const hw_uint<32> value) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 1 reading from capacity: 7 f2 = f1.back(); #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 7 reading from capacity: 1 f1.push(f0); // cap: 1 f0 = value; } }; struct in_in_update_0_write2_merged_banks_2_cache { // RAM Box: {[2, 114], [0, 127], [0, 31]} // Capacity: 9 // # of read delays: 2 hw_uint<32> f0; fifo<hw_uint<32> , 7> f1; hw_uint<32> f2; inline hw_uint<32> peek_0() { return f0; } inline hw_uint<32> peek_7() { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ return f1.back(); } inline hw_uint<32> peek_8() { return f2; } inline void push(const hw_uint<32> value) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 1 reading from capacity: 7 f2 = f1.back(); #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 7 reading from capacity: 1 f1.push(f0); // cap: 1 f0 = value; } }; struct in_in_update_0_write3_merged_banks_2_cache { // RAM Box: {[3, 115], [0, 127], [0, 31]} // Capacity: 9 // # of read delays: 2 hw_uint<32> f0; fifo<hw_uint<32> , 7> f1; hw_uint<32> f2; inline hw_uint<32> peek_0() { return f0; } inline hw_uint<32> peek_7() { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ return f1.back(); } inline hw_uint<32> peek_8() { return f2; } inline void push(const hw_uint<32> value) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 1 reading from capacity: 7 f2 = f1.back(); #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 7 reading from capacity: 1 f1.push(f0); // cap: 1 f0 = value; } }; struct in_in_update_0_write4_merged_banks_2_cache { // RAM Box: {[4, 116], [0, 127], [0, 31]} // Capacity: 9 // # of read delays: 2 hw_uint<32> f0; fifo<hw_uint<32> , 7> f1; hw_uint<32> f2; inline hw_uint<32> peek_0() { return f0; } inline hw_uint<32> peek_7() { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ return f1.back(); } inline hw_uint<32> peek_8() { return f2; } inline void push(const hw_uint<32> value) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 1 reading from capacity: 7 f2 = f1.back(); #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 7 reading from capacity: 1 f1.push(f0); // cap: 1 f0 = value; } }; struct in_in_update_0_write5_merged_banks_2_cache { // RAM Box: {[5, 117], [0, 127], [0, 31]} // Capacity: 9 // # of read delays: 2 hw_uint<32> f0; fifo<hw_uint<32> , 7> f1; hw_uint<32> f2; inline hw_uint<32> peek_0() { return f0; } inline hw_uint<32> peek_7() { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ return f1.back(); } inline hw_uint<32> peek_8() { return f2; } inline void push(const hw_uint<32> value) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 1 reading from capacity: 7 f2 = f1.back(); #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 7 reading from capacity: 1 f1.push(f0); // cap: 1 f0 = value; } }; struct in_in_update_0_write6_merged_banks_2_cache { // RAM Box: {[6, 118], [0, 127], [0, 31]} // Capacity: 9 // # of read delays: 2 hw_uint<32> f0; fifo<hw_uint<32> , 7> f1; hw_uint<32> f2; inline hw_uint<32> peek_0() { return f0; } inline hw_uint<32> peek_7() { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ return f1.back(); } inline hw_uint<32> peek_8() { return f2; } inline void push(const hw_uint<32> value) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 1 reading from capacity: 7 f2 = f1.back(); #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 7 reading from capacity: 1 f1.push(f0); // cap: 1 f0 = value; } }; struct in_in_update_0_write7_merged_banks_2_cache { // RAM Box: {[7, 119], [0, 127], [0, 31]} // Capacity: 9 // # of read delays: 2 hw_uint<32> f0; fifo<hw_uint<32> , 7> f1; hw_uint<32> f2; inline hw_uint<32> peek_0() { return f0; } inline hw_uint<32> peek_7() { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ return f1.back(); } inline hw_uint<32> peek_8() { return f2; } inline void push(const hw_uint<32> value) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 1 reading from capacity: 7 f2 = f1.back(); #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 7 reading from capacity: 1 f1.push(f0); // cap: 1 f0 = value; } }; struct in_in_update_0_write8_merged_banks_2_cache { // RAM Box: {[8, 120], [0, 127], [0, 31]} // Capacity: 9 // # of read delays: 2 hw_uint<32> f0; fifo<hw_uint<32> , 7> f1; hw_uint<32> f2; inline hw_uint<32> peek_0() { return f0; } inline hw_uint<32> peek_7() { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ return f1.back(); } inline hw_uint<32> peek_8() { return f2; } inline void push(const hw_uint<32> value) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 1 reading from capacity: 7 f2 = f1.back(); #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 7 reading from capacity: 1 f1.push(f0); // cap: 1 f0 = value; } }; struct in_in_update_0_write9_merged_banks_2_cache { // RAM Box: {[9, 121], [0, 127], [0, 31]} // Capacity: 9 // # of read delays: 2 hw_uint<32> f0; fifo<hw_uint<32> , 7> f1; hw_uint<32> f2; inline hw_uint<32> peek_0() { return f0; } inline hw_uint<32> peek_7() { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ return f1.back(); } inline hw_uint<32> peek_8() { return f2; } inline void push(const hw_uint<32> value) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 1 reading from capacity: 7 f2 = f1.back(); #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // cap: 7 reading from capacity: 1 f1.push(f0); // cap: 1 f0 = value; } }; struct in_cache { in_in_update_0_write0_merged_banks_2_cache in_in_update_0_write0_merged_banks_2; in_in_update_0_write1_merged_banks_2_cache in_in_update_0_write1_merged_banks_2; in_in_update_0_write10_merged_banks_2_cache in_in_update_0_write10_merged_banks_2; in_in_update_0_write11_merged_banks_2_cache in_in_update_0_write11_merged_banks_2; in_in_update_0_write12_merged_banks_2_cache in_in_update_0_write12_merged_banks_2; in_in_update_0_write13_merged_banks_2_cache in_in_update_0_write13_merged_banks_2; in_in_update_0_write14_merged_banks_2_cache in_in_update_0_write14_merged_banks_2; in_in_update_0_write15_merged_banks_2_cache in_in_update_0_write15_merged_banks_2; in_in_update_0_write2_merged_banks_2_cache in_in_update_0_write2_merged_banks_2; in_in_update_0_write3_merged_banks_2_cache in_in_update_0_write3_merged_banks_2; in_in_update_0_write4_merged_banks_2_cache in_in_update_0_write4_merged_banks_2; in_in_update_0_write5_merged_banks_2_cache in_in_update_0_write5_merged_banks_2; in_in_update_0_write6_merged_banks_2_cache in_in_update_0_write6_merged_banks_2; in_in_update_0_write7_merged_banks_2_cache in_in_update_0_write7_merged_banks_2; in_in_update_0_write8_merged_banks_2_cache in_in_update_0_write8_merged_banks_2; in_in_update_0_write9_merged_banks_2_cache in_in_update_0_write9_merged_banks_2; }; inline void in_in_update_0_write0_write(hw_uint<32> & in_in_update_0_write0, in_cache& in, int d0, int d1, int d2) { in.in_in_update_0_write0_merged_banks_2.push(in_in_update_0_write0); } inline void in_in_update_0_write1_write(hw_uint<32> & in_in_update_0_write1, in_cache& in, int d0, int d1, int d2) { in.in_in_update_0_write1_merged_banks_2.push(in_in_update_0_write1); } inline void in_in_update_0_write10_write(hw_uint<32> & in_in_update_0_write10, in_cache& in, int d0, int d1, int d2) { in.in_in_update_0_write10_merged_banks_2.push(in_in_update_0_write10); } inline void in_in_update_0_write11_write(hw_uint<32> & in_in_update_0_write11, in_cache& in, int d0, int d1, int d2) { in.in_in_update_0_write11_merged_banks_2.push(in_in_update_0_write11); } inline void in_in_update_0_write12_write(hw_uint<32> & in_in_update_0_write12, in_cache& in, int d0, int d1, int d2) { in.in_in_update_0_write12_merged_banks_2.push(in_in_update_0_write12); } inline void in_in_update_0_write13_write(hw_uint<32> & in_in_update_0_write13, in_cache& in, int d0, int d1, int d2) { in.in_in_update_0_write13_merged_banks_2.push(in_in_update_0_write13); } inline void in_in_update_0_write14_write(hw_uint<32> & in_in_update_0_write14, in_cache& in, int d0, int d1, int d2) { in.in_in_update_0_write14_merged_banks_2.push(in_in_update_0_write14); } inline void in_in_update_0_write15_write(hw_uint<32> & in_in_update_0_write15, in_cache& in, int d0, int d1, int d2) { in.in_in_update_0_write15_merged_banks_2.push(in_in_update_0_write15); } inline void in_in_update_0_write2_write(hw_uint<32> & in_in_update_0_write2, in_cache& in, int d0, int d1, int d2) { in.in_in_update_0_write2_merged_banks_2.push(in_in_update_0_write2); } inline void in_in_update_0_write3_write(hw_uint<32> & in_in_update_0_write3, in_cache& in, int d0, int d1, int d2) { in.in_in_update_0_write3_merged_banks_2.push(in_in_update_0_write3); } inline void in_in_update_0_write4_write(hw_uint<32> & in_in_update_0_write4, in_cache& in, int d0, int d1, int d2) { in.in_in_update_0_write4_merged_banks_2.push(in_in_update_0_write4); } inline void in_in_update_0_write5_write(hw_uint<32> & in_in_update_0_write5, in_cache& in, int d0, int d1, int d2) { in.in_in_update_0_write5_merged_banks_2.push(in_in_update_0_write5); } inline void in_in_update_0_write6_write(hw_uint<32> & in_in_update_0_write6, in_cache& in, int d0, int d1, int d2) { in.in_in_update_0_write6_merged_banks_2.push(in_in_update_0_write6); } inline void in_in_update_0_write7_write(hw_uint<32> & in_in_update_0_write7, in_cache& in, int d0, int d1, int d2) { in.in_in_update_0_write7_merged_banks_2.push(in_in_update_0_write7); } inline void in_in_update_0_write8_write(hw_uint<32> & in_in_update_0_write8, in_cache& in, int d0, int d1, int d2) { in.in_in_update_0_write8_merged_banks_2.push(in_in_update_0_write8); } inline void in_in_update_0_write9_write(hw_uint<32> & in_in_update_0_write9, in_cache& in, int d0, int d1, int d2) { in.in_in_update_0_write9_merged_banks_2.push(in_in_update_0_write9); } inline hw_uint<32> mp_16_rd0_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd0 read pattern: { mp_16_update_0[d0, d1, d2] -> in[16d0, 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { mp_16_update_0[d0, d1, d2] -> 8 : 0 < d0 <= 6 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> (1 + d0) : d0 = 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> 8 : d0 = 0 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } auto value_in_in_update_0_write0 = in.in_in_update_0_write0_merged_banks_2.peek_8(); return value_in_in_update_0_write0; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd1_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd1 read pattern: { mp_16_update_0[d0, d1, d2] -> in[16d0, 1 + 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { } auto value_in_in_update_0_write0 = in.in_in_update_0_write0_merged_banks_2.peek_0(); return value_in_in_update_0_write0; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd10_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd10 read pattern: { mp_16_update_0[d0, d1, d2] -> in[5 + 16d0, 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { mp_16_update_0[d0, d1, d2] -> 8 : 0 < d0 <= 6 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> (1 + d0) : d0 = 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> 8 : d0 = 0 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } auto value_in_in_update_0_write5 = in.in_in_update_0_write5_merged_banks_2.peek_8(); return value_in_in_update_0_write5; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd11_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd11 read pattern: { mp_16_update_0[d0, d1, d2] -> in[5 + 16d0, 1 + 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { } auto value_in_in_update_0_write5 = in.in_in_update_0_write5_merged_banks_2.peek_0(); return value_in_in_update_0_write5; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd12_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd12 read pattern: { mp_16_update_0[d0, d1, d2] -> in[6 + 16d0, 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { mp_16_update_0[d0, d1, d2] -> 8 : 0 < d0 <= 6 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> (1 + d0) : d0 = 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> 8 : d0 = 0 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } auto value_in_in_update_0_write6 = in.in_in_update_0_write6_merged_banks_2.peek_8(); return value_in_in_update_0_write6; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd13_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd13 read pattern: { mp_16_update_0[d0, d1, d2] -> in[6 + 16d0, 1 + 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { } auto value_in_in_update_0_write6 = in.in_in_update_0_write6_merged_banks_2.peek_0(); return value_in_in_update_0_write6; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd14_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd14 read pattern: { mp_16_update_0[d0, d1, d2] -> in[7 + 16d0, 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { mp_16_update_0[d0, d1, d2] -> 8 : 0 < d0 <= 6 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> (1 + d0) : d0 = 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> 8 : d0 = 0 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } auto value_in_in_update_0_write7 = in.in_in_update_0_write7_merged_banks_2.peek_8(); return value_in_in_update_0_write7; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd15_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd15 read pattern: { mp_16_update_0[d0, d1, d2] -> in[7 + 16d0, 1 + 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { } auto value_in_in_update_0_write7 = in.in_in_update_0_write7_merged_banks_2.peek_0(); return value_in_in_update_0_write7; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd16_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd16 read pattern: { mp_16_update_0[d0, d1, d2] -> in[8 + 16d0, 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { mp_16_update_0[d0, d1, d2] -> 8 : 0 < d0 <= 6 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> (1 + d0) : d0 = 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> 8 : d0 = 0 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } auto value_in_in_update_0_write8 = in.in_in_update_0_write8_merged_banks_2.peek_8(); return value_in_in_update_0_write8; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd17_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd17 read pattern: { mp_16_update_0[d0, d1, d2] -> in[8 + 16d0, 1 + 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { } auto value_in_in_update_0_write8 = in.in_in_update_0_write8_merged_banks_2.peek_0(); return value_in_in_update_0_write8; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd18_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd18 read pattern: { mp_16_update_0[d0, d1, d2] -> in[9 + 16d0, 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { mp_16_update_0[d0, d1, d2] -> 8 : 0 < d0 <= 6 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> (1 + d0) : d0 = 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> 8 : d0 = 0 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } auto value_in_in_update_0_write9 = in.in_in_update_0_write9_merged_banks_2.peek_8(); return value_in_in_update_0_write9; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd19_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd19 read pattern: { mp_16_update_0[d0, d1, d2] -> in[9 + 16d0, 1 + 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { } auto value_in_in_update_0_write9 = in.in_in_update_0_write9_merged_banks_2.peek_0(); return value_in_in_update_0_write9; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd2_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd2 read pattern: { mp_16_update_0[d0, d1, d2] -> in[1 + 16d0, 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { mp_16_update_0[d0, d1, d2] -> 8 : 0 < d0 <= 6 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> (1 + d0) : d0 = 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> 8 : d0 = 0 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } auto value_in_in_update_0_write1 = in.in_in_update_0_write1_merged_banks_2.peek_8(); return value_in_in_update_0_write1; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd20_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd20 read pattern: { mp_16_update_0[d0, d1, d2] -> in[10 + 16d0, 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { mp_16_update_0[d0, d1, d2] -> 8 : 0 < d0 <= 6 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> (1 + d0) : d0 = 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> 8 : d0 = 0 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } auto value_in_in_update_0_write10 = in.in_in_update_0_write10_merged_banks_2.peek_8(); return value_in_in_update_0_write10; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd21_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd21 read pattern: { mp_16_update_0[d0, d1, d2] -> in[10 + 16d0, 1 + 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { } auto value_in_in_update_0_write10 = in.in_in_update_0_write10_merged_banks_2.peek_0(); return value_in_in_update_0_write10; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd22_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd22 read pattern: { mp_16_update_0[d0, d1, d2] -> in[11 + 16d0, 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { mp_16_update_0[d0, d1, d2] -> 8 : 0 < d0 <= 6 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> (1 + d0) : d0 = 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> 8 : d0 = 0 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } auto value_in_in_update_0_write11 = in.in_in_update_0_write11_merged_banks_2.peek_8(); return value_in_in_update_0_write11; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd23_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd23 read pattern: { mp_16_update_0[d0, d1, d2] -> in[11 + 16d0, 1 + 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { } auto value_in_in_update_0_write11 = in.in_in_update_0_write11_merged_banks_2.peek_0(); return value_in_in_update_0_write11; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd24_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd24 read pattern: { mp_16_update_0[d0, d1, d2] -> in[12 + 16d0, 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { mp_16_update_0[d0, d1, d2] -> 8 : 0 < d0 <= 6 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> (1 + d0) : d0 = 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> 8 : d0 = 0 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } auto value_in_in_update_0_write12 = in.in_in_update_0_write12_merged_banks_2.peek_8(); return value_in_in_update_0_write12; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd25_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd25 read pattern: { mp_16_update_0[d0, d1, d2] -> in[12 + 16d0, 1 + 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { } auto value_in_in_update_0_write12 = in.in_in_update_0_write12_merged_banks_2.peek_0(); return value_in_in_update_0_write12; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd26_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd26 read pattern: { mp_16_update_0[d0, d1, d2] -> in[13 + 16d0, 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { mp_16_update_0[d0, d1, d2] -> 8 : 0 < d0 <= 6 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> (1 + d0) : d0 = 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> 8 : d0 = 0 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } auto value_in_in_update_0_write13 = in.in_in_update_0_write13_merged_banks_2.peek_8(); return value_in_in_update_0_write13; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd27_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd27 read pattern: { mp_16_update_0[d0, d1, d2] -> in[13 + 16d0, 1 + 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { } auto value_in_in_update_0_write13 = in.in_in_update_0_write13_merged_banks_2.peek_0(); return value_in_in_update_0_write13; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd28_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd28 read pattern: { mp_16_update_0[d0, d1, d2] -> in[14 + 16d0, 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { mp_16_update_0[d0, d1, d2] -> 8 : 0 < d0 <= 6 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> (1 + d0) : d0 = 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> 8 : d0 = 0 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } auto value_in_in_update_0_write14 = in.in_in_update_0_write14_merged_banks_2.peek_8(); return value_in_in_update_0_write14; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd29_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd29 read pattern: { mp_16_update_0[d0, d1, d2] -> in[14 + 16d0, 1 + 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { } auto value_in_in_update_0_write14 = in.in_in_update_0_write14_merged_banks_2.peek_0(); return value_in_in_update_0_write14; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd3_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd3 read pattern: { mp_16_update_0[d0, d1, d2] -> in[1 + 16d0, 1 + 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { } auto value_in_in_update_0_write1 = in.in_in_update_0_write1_merged_banks_2.peek_0(); return value_in_in_update_0_write1; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd30_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd30 read pattern: { mp_16_update_0[d0, d1, d2] -> in[15 + 16d0, 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { mp_16_update_0[d0, d1, d2] -> 8 : 0 < d0 <= 6 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> (1 + d0) : d0 = 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> 8 : d0 = 0 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } auto value_in_in_update_0_write15 = in.in_in_update_0_write15_merged_banks_2.peek_8(); return value_in_in_update_0_write15; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd31_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd31 read pattern: { mp_16_update_0[d0, d1, d2] -> in[15 + 16d0, 1 + 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { } auto value_in_in_update_0_write15 = in.in_in_update_0_write15_merged_banks_2.peek_0(); return value_in_in_update_0_write15; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd4_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd4 read pattern: { mp_16_update_0[d0, d1, d2] -> in[2 + 16d0, 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { mp_16_update_0[d0, d1, d2] -> 8 : 0 < d0 <= 6 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> (1 + d0) : d0 = 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> 8 : d0 = 0 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } auto value_in_in_update_0_write2 = in.in_in_update_0_write2_merged_banks_2.peek_8(); return value_in_in_update_0_write2; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd5_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd5 read pattern: { mp_16_update_0[d0, d1, d2] -> in[2 + 16d0, 1 + 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { } auto value_in_in_update_0_write2 = in.in_in_update_0_write2_merged_banks_2.peek_0(); return value_in_in_update_0_write2; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd6_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd6 read pattern: { mp_16_update_0[d0, d1, d2] -> in[3 + 16d0, 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { mp_16_update_0[d0, d1, d2] -> 8 : 0 < d0 <= 6 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> (1 + d0) : d0 = 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> 8 : d0 = 0 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } auto value_in_in_update_0_write3 = in.in_in_update_0_write3_merged_banks_2.peek_8(); return value_in_in_update_0_write3; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd7_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd7 read pattern: { mp_16_update_0[d0, d1, d2] -> in[3 + 16d0, 1 + 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { } auto value_in_in_update_0_write3 = in.in_in_update_0_write3_merged_banks_2.peek_0(); return value_in_in_update_0_write3; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd8_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd8 read pattern: { mp_16_update_0[d0, d1, d2] -> in[4 + 16d0, 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { mp_16_update_0[d0, d1, d2] -> 8 : 0 < d0 <= 6 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> (1 + d0) : d0 = 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31; mp_16_update_0[d0, d1, d2] -> 8 : d0 = 0 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } auto value_in_in_update_0_write4 = in.in_in_update_0_write4_merged_banks_2.peek_8(); return value_in_in_update_0_write4; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } inline hw_uint<32> mp_16_rd9_select(in_cache& in, int d0, int d1, int d2) { #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ // mp_16_rd9 read pattern: { mp_16_update_0[d0, d1, d2] -> in[4 + 16d0, 1 + 2d1, d2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Read schedule : { mp_16_update_0[d0, d1, d2] -> [d2, 1 + 2d1, d0, 2] : 0 <= d0 <= 7 and 0 <= d1 <= 63 and 0 <= d2 <= 31 } // Write schedule: { in_update_0[d0, d1, d2] -> [d2, d1, d0, 1] : 0 <= d0 <= 7 and 0 <= d1 <= 127 and 0 <= d2 <= 31 } // DD fold: { } auto value_in_in_update_0_write4 = in.in_in_update_0_write4_merged_banks_2.peek_0(); return value_in_in_update_0_write4; #ifndef __VIVADO_SYNTH__ cout << "Error: Unsupported offsets: " << " d0 = " << d0 << " d1 = " << d1 << " d2 = " << d2 << endl; assert(false); return 0; #endif //__VIVADO_SYNTH__ } // # of bundles = 2 // in_update_0_write // in_in_update_0_write0 // in_in_update_0_write1 // in_in_update_0_write2 // in_in_update_0_write3 // in_in_update_0_write4 // in_in_update_0_write5 // in_in_update_0_write6 // in_in_update_0_write7 // in_in_update_0_write8 // in_in_update_0_write9 // in_in_update_0_write10 // in_in_update_0_write11 // in_in_update_0_write12 // in_in_update_0_write13 // in_in_update_0_write14 // in_in_update_0_write15 inline void in_in_update_0_write_bundle_write(hw_uint<512>& in_update_0_write, in_cache& in, int d0, int d1, int d2) { hw_uint<32> in_in_update_0_write0_res = in_update_0_write.extract<0, 31>(); in_in_update_0_write0_write(in_in_update_0_write0_res, in, d0, d1, d2); hw_uint<32> in_in_update_0_write1_res = in_update_0_write.extract<32, 63>(); in_in_update_0_write1_write(in_in_update_0_write1_res, in, d0, d1, d2); hw_uint<32> in_in_update_0_write2_res = in_update_0_write.extract<64, 95>(); in_in_update_0_write2_write(in_in_update_0_write2_res, in, d0, d1, d2); hw_uint<32> in_in_update_0_write3_res = in_update_0_write.extract<96, 127>(); in_in_update_0_write3_write(in_in_update_0_write3_res, in, d0, d1, d2); hw_uint<32> in_in_update_0_write4_res = in_update_0_write.extract<128, 159>(); in_in_update_0_write4_write(in_in_update_0_write4_res, in, d0, d1, d2); hw_uint<32> in_in_update_0_write5_res = in_update_0_write.extract<160, 191>(); in_in_update_0_write5_write(in_in_update_0_write5_res, in, d0, d1, d2); hw_uint<32> in_in_update_0_write6_res = in_update_0_write.extract<192, 223>(); in_in_update_0_write6_write(in_in_update_0_write6_res, in, d0, d1, d2); hw_uint<32> in_in_update_0_write7_res = in_update_0_write.extract<224, 255>(); in_in_update_0_write7_write(in_in_update_0_write7_res, in, d0, d1, d2); hw_uint<32> in_in_update_0_write8_res = in_update_0_write.extract<256, 287>(); in_in_update_0_write8_write(in_in_update_0_write8_res, in, d0, d1, d2); hw_uint<32> in_in_update_0_write9_res = in_update_0_write.extract<288, 319>(); in_in_update_0_write9_write(in_in_update_0_write9_res, in, d0, d1, d2); hw_uint<32> in_in_update_0_write10_res = in_update_0_write.extract<320, 351>(); in_in_update_0_write10_write(in_in_update_0_write10_res, in, d0, d1, d2); hw_uint<32> in_in_update_0_write11_res = in_update_0_write.extract<352, 383>(); in_in_update_0_write11_write(in_in_update_0_write11_res, in, d0, d1, d2); hw_uint<32> in_in_update_0_write12_res = in_update_0_write.extract<384, 415>(); in_in_update_0_write12_write(in_in_update_0_write12_res, in, d0, d1, d2); hw_uint<32> in_in_update_0_write13_res = in_update_0_write.extract<416, 447>(); in_in_update_0_write13_write(in_in_update_0_write13_res, in, d0, d1, d2); hw_uint<32> in_in_update_0_write14_res = in_update_0_write.extract<448, 479>(); in_in_update_0_write14_write(in_in_update_0_write14_res, in, d0, d1, d2); hw_uint<32> in_in_update_0_write15_res = in_update_0_write.extract<480, 511>(); in_in_update_0_write15_write(in_in_update_0_write15_res, in, d0, d1, d2); } // mp_16_update_0_read // mp_16_rd0 // mp_16_rd1 // mp_16_rd2 // mp_16_rd3 // mp_16_rd4 // mp_16_rd5 // mp_16_rd6 // mp_16_rd7 // mp_16_rd8 // mp_16_rd9 // mp_16_rd10 // mp_16_rd11 // mp_16_rd12 // mp_16_rd13 // mp_16_rd14 // mp_16_rd15 // mp_16_rd16 // mp_16_rd17 // mp_16_rd18 // mp_16_rd19 // mp_16_rd20 // mp_16_rd21 // mp_16_rd22 // mp_16_rd23 // mp_16_rd24 // mp_16_rd25 // mp_16_rd26 // mp_16_rd27 // mp_16_rd28 // mp_16_rd29 // mp_16_rd30 // mp_16_rd31 inline hw_uint<1024> in_mp_16_update_0_read_bundle_read(in_cache& in, int d0, int d1, int d2) { // # of ports in bundle: 32 // mp_16_rd0 // mp_16_rd1 // mp_16_rd2 // mp_16_rd3 // mp_16_rd4 // mp_16_rd5 // mp_16_rd6 // mp_16_rd7 // mp_16_rd8 // mp_16_rd9 // mp_16_rd10 // mp_16_rd11 // mp_16_rd12 // mp_16_rd13 // mp_16_rd14 // mp_16_rd15 // mp_16_rd16 // mp_16_rd17 // mp_16_rd18 // mp_16_rd19 // mp_16_rd20 // mp_16_rd21 // mp_16_rd22 // mp_16_rd23 // mp_16_rd24 // mp_16_rd25 // mp_16_rd26 // mp_16_rd27 // mp_16_rd28 // mp_16_rd29 // mp_16_rd30 // mp_16_rd31 hw_uint<1024> result; hw_uint<32> mp_16_rd0_res = mp_16_rd0_select(in, d0, d1, d2); set_at<0, 1024>(result, mp_16_rd0_res); hw_uint<32> mp_16_rd1_res = mp_16_rd1_select(in, d0, d1, d2); set_at<32, 1024>(result, mp_16_rd1_res); hw_uint<32> mp_16_rd2_res = mp_16_rd2_select(in, d0, d1, d2); set_at<64, 1024>(result, mp_16_rd2_res); hw_uint<32> mp_16_rd3_res = mp_16_rd3_select(in, d0, d1, d2); set_at<96, 1024>(result, mp_16_rd3_res); hw_uint<32> mp_16_rd4_res = mp_16_rd4_select(in, d0, d1, d2); set_at<128, 1024>(result, mp_16_rd4_res); hw_uint<32> mp_16_rd5_res = mp_16_rd5_select(in, d0, d1, d2); set_at<160, 1024>(result, mp_16_rd5_res); hw_uint<32> mp_16_rd6_res = mp_16_rd6_select(in, d0, d1, d2); set_at<192, 1024>(result, mp_16_rd6_res); hw_uint<32> mp_16_rd7_res = mp_16_rd7_select(in, d0, d1, d2); set_at<224, 1024>(result, mp_16_rd7_res); hw_uint<32> mp_16_rd8_res = mp_16_rd8_select(in, d0, d1, d2); set_at<256, 1024>(result, mp_16_rd8_res); hw_uint<32> mp_16_rd9_res = mp_16_rd9_select(in, d0, d1, d2); set_at<288, 1024>(result, mp_16_rd9_res); hw_uint<32> mp_16_rd10_res = mp_16_rd10_select(in, d0, d1, d2); set_at<320, 1024>(result, mp_16_rd10_res); hw_uint<32> mp_16_rd11_res = mp_16_rd11_select(in, d0, d1, d2); set_at<352, 1024>(result, mp_16_rd11_res); hw_uint<32> mp_16_rd12_res = mp_16_rd12_select(in, d0, d1, d2); set_at<384, 1024>(result, mp_16_rd12_res); hw_uint<32> mp_16_rd13_res = mp_16_rd13_select(in, d0, d1, d2); set_at<416, 1024>(result, mp_16_rd13_res); hw_uint<32> mp_16_rd14_res = mp_16_rd14_select(in, d0, d1, d2); set_at<448, 1024>(result, mp_16_rd14_res); hw_uint<32> mp_16_rd15_res = mp_16_rd15_select(in, d0, d1, d2); set_at<480, 1024>(result, mp_16_rd15_res); hw_uint<32> mp_16_rd16_res = mp_16_rd16_select(in, d0, d1, d2); set_at<512, 1024>(result, mp_16_rd16_res); hw_uint<32> mp_16_rd17_res = mp_16_rd17_select(in, d0, d1, d2); set_at<544, 1024>(result, mp_16_rd17_res); hw_uint<32> mp_16_rd18_res = mp_16_rd18_select(in, d0, d1, d2); set_at<576, 1024>(result, mp_16_rd18_res); hw_uint<32> mp_16_rd19_res = mp_16_rd19_select(in, d0, d1, d2); set_at<608, 1024>(result, mp_16_rd19_res); hw_uint<32> mp_16_rd20_res = mp_16_rd20_select(in, d0, d1, d2); set_at<640, 1024>(result, mp_16_rd20_res); hw_uint<32> mp_16_rd21_res = mp_16_rd21_select(in, d0, d1, d2); set_at<672, 1024>(result, mp_16_rd21_res); hw_uint<32> mp_16_rd22_res = mp_16_rd22_select(in, d0, d1, d2); set_at<704, 1024>(result, mp_16_rd22_res); hw_uint<32> mp_16_rd23_res = mp_16_rd23_select(in, d0, d1, d2); set_at<736, 1024>(result, mp_16_rd23_res); hw_uint<32> mp_16_rd24_res = mp_16_rd24_select(in, d0, d1, d2); set_at<768, 1024>(result, mp_16_rd24_res); hw_uint<32> mp_16_rd25_res = mp_16_rd25_select(in, d0, d1, d2); set_at<800, 1024>(result, mp_16_rd25_res); hw_uint<32> mp_16_rd26_res = mp_16_rd26_select(in, d0, d1, d2); set_at<832, 1024>(result, mp_16_rd26_res); hw_uint<32> mp_16_rd27_res = mp_16_rd27_select(in, d0, d1, d2); set_at<864, 1024>(result, mp_16_rd27_res); hw_uint<32> mp_16_rd28_res = mp_16_rd28_select(in, d0, d1, d2); set_at<896, 1024>(result, mp_16_rd28_res); hw_uint<32> mp_16_rd29_res = mp_16_rd29_select(in, d0, d1, d2); set_at<928, 1024>(result, mp_16_rd29_res); hw_uint<32> mp_16_rd30_res = mp_16_rd30_select(in, d0, d1, d2); set_at<960, 1024>(result, mp_16_rd30_res); hw_uint<32> mp_16_rd31_res = mp_16_rd31_select(in, d0, d1, d2); set_at<992, 1024>(result, mp_16_rd31_res); return result; } // Operation logic inline void in_update_0(HWStream<hw_uint<512> >& /* buffer_args num ports = 16 */in_oc, in_cache& in, int d0, int d1, int d2) { // Consume: in_oc auto in_oc_0_c__0_value = in_oc.read(); auto compute_result = id_unrolled_16(in_oc_0_c__0_value); // Produce: in in_in_update_0_write_bundle_write(compute_result, in, d0, d1, d2); #ifndef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ } inline void mp_16_update_0(in_cache& in, HWStream<hw_uint<256> >& /* buffer_args num ports = 8 */mp_16, int d0, int d1, int d2) { // Consume: in auto in_0_c__0_value = in_mp_16_update_0_read_bundle_read(in/* source_delay */, d0, d1, d2); #ifndef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ auto compute_result = max_pool_2x2_unrolled_8(in_0_c__0_value); // Produce: mp_16 mp_16.write(compute_result); #ifndef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ } // Driver function void mp_16_opt(HWStream<hw_uint<512> >& /* get_args num ports = 16 */in_oc, HWStream<hw_uint<256> >& /* get_args num ports = 8 */mp_16, int num_epochs) { #ifndef __VIVADO_SYNTH__ ofstream debug_file("mp_16_opt_debug.csv"); global_debug_handle = &debug_file; #endif //__VIVADO_SYNTH__ in_cache in; #ifdef __VIVADO_SYNTH__ #endif //__VIVADO_SYNTH__ #ifdef __VIVADO_SYNTH__ #pragma HLS inline recursive #endif // __VIVADO_SYNTH__ for (int epoch = 0; epoch < num_epochs; epoch++) { // Schedules... // in_oc_update_0 -> [1*d2*1*1 + 1*0,1*d1*1*1 + 1*0,1*d0*1*1 + 1*0,1*0] // in_update_0 -> [1*d2*1*1 + 1*0,1*d1*1*1 + 1*0,1*d0*1*1 + 1*0,1*1] // mp_16_update_0 -> [1*d2*1*1 + 1*0,1*d1*1*2 + 1*1,1*d0*1*1 + 1*0,1*2] for (int c0 = 0; c0 <= 31; c0++) { for (int c1 = 0; c1 <= 127; c1++) { for (int c2 = 0; c2 <= 7; c2++) { #ifdef __VIVADO_SYNTH__ #pragma HLS pipeline II=1 #endif // __VIVADO_SYNTH__ if ((0 <= c2 && c2 <= 7) && ((c2 - 0) % 1 == 0) && (0 <= c1 && c1 <= 127) && ((c1 - 0) % 1 == 0) && (0 <= c0 && c0 <= 31) && ((c0 - 0) % 1 == 0)) { in_update_0(in_oc, in, (c2 - 0) / 1, (c1 - 0) / 1, (c0 - 0) / 1); } if ((0 <= c2 && c2 <= 7) && ((c2 - 0) % 1 == 0) && (1 <= c1 && c1 <= 127) && ((c1 - 1) % 2 == 0) && (0 <= c0 && c0 <= 31) && ((c0 - 0) % 1 == 0)) { mp_16_update_0(in, mp_16, (c2 - 0) / 1, (c1 - 1) / 2, (c0 - 0) / 1); } } } } } #ifndef __VIVADO_SYNTH__ debug_file.close(); #endif //__VIVADO_SYNTH__ } void mp_16_opt(HWStream<hw_uint<512> >& /* get_args num ports = 16 */in_oc, HWStream<hw_uint<256> >& /* get_args num ports = 8 */mp_16) { mp_16_opt(in_oc, mp_16, 1); } #ifdef __VIVADO_SYNTH__ #include "mp_16_opt.h" const int in_update_0_read_num_transfers = 32768; const int mp_16_update_0_write_num_transfers = 16384; extern "C" { static void read_in_update_0_read(hw_uint<512>* input, HWStream<hw_uint<512> >& v, const int size) { hw_uint<512> burst_reg; int num_transfers = in_update_0_read_num_transfers*size; for (int i = 0; i < num_transfers; i++) { #pragma HLS pipeline II=1 burst_reg = input[i]; v.write(burst_reg); } } static void write_mp_16_update_0_write(hw_uint<256>* output, HWStream<hw_uint<256> >& v, const int size) { hw_uint<256> burst_reg; int num_transfers = mp_16_update_0_write_num_transfers*size; for (int i = 0; i < num_transfers; i++) { #pragma HLS pipeline II=1 burst_reg = v.read(); output[i] = burst_reg; } } void mp_16_opt_accel(hw_uint<512>* in_update_0_read, hw_uint<256>* mp_16_update_0_write, const int size) { #pragma HLS dataflow #pragma HLS INTERFACE m_axi port = in_update_0_read offset = slave depth = 65536 bundle = gmem0 #pragma HLS INTERFACE m_axi port = mp_16_update_0_write offset = slave depth = 65536 bundle = gmem1 #pragma HLS INTERFACE s_axilite port = in_update_0_read bundle = control #pragma HLS INTERFACE s_axilite port = mp_16_update_0_write bundle = control #pragma HLS INTERFACE s_axilite port = size bundle = control #pragma HLS INTERFACE s_axilite port = return bundle = control static HWStream<hw_uint<512> > in_update_0_read_channel; static HWStream<hw_uint<256> > mp_16_update_0_write_channel; read_in_update_0_read(in_update_0_read, in_update_0_read_channel, size); mp_16_opt(in_update_0_read_channel, mp_16_update_0_write_channel, size); write_mp_16_update_0_write(mp_16_update_0_write, mp_16_update_0_write_channel, size); } } #endif //__VIVADO_SYNTH__
#include <iostream> #include <cstdlib> #include <cstdio> #include "TFile.h" #include "TCanvas.h" #include "TH2F.h" int main(int argc, char **argv) { if (argc<=1) { printf("*** wrong # cli args ***\n"); exit(1); } std::string filename{argv[1]}; TFile f{filename.c_str()}; auto *e_cpuvsgpu_mahi = dynamic_cast<TH2F*>( f.Get("comparisonPlots/hEnergy_cpuvsgpu_mahi")); auto c = new TCanvas("c1","Canvas Example",200,10,1024, 760); e_cpuvsgpu_mahi->SetTitle("Hcal Reconstruction (MAHI) GPU vs CPU"); e_cpuvsgpu_mahi->Draw("colz"); c->SaveAs("energy_cpuvsgpu_mahi.png"); return 0; }
#include "UIFactory.h" #include "Button.h" #include "VisionCone.h" using namespace uth; using namespace pmath; GameObject* UIFactory::CreateButton(const Rect& area, const std::string& texture, ButtonType type, const ButtonCallback& callback) { auto go = new GameObject(); go->AddTags({ "UI", "Text" }); go->AddComponent(new Sprite(texture)); go->AddComponent(new Button(type, callback)); go->transform.SetPosition(area.position); go->transform.ScaleToSize(area.size); return go; } uth::GameObject* UIFactory::CreateText(const Rect& area, const std::string& font, float fontSize, const std::string& text, int origin, const Vec4& color) { auto go = new GameObject(); /* DISABLED until engine update / std::fprintf(stderr, "[DEPRACTED] UIFactory::CreateText is depracted, until further notice."); std::abort(); / ---------------------------- */ go->AddTags({ "UI", "Text" }); { auto c = new Text(font, fontSize); c->SetColor(color); c->SetText(text); go->AddComponent(c); } go->transform.SetPosition(area.position); go->transform.ScaleToSize(area.size); go->transform.SetOrigin(origin); /* ---------------------------- */ return go; } uth::GameObject* UIFactory::CreateBuildGuide() { auto go = new GameObject(); go->AddTags({ "UI", "BuildGuide" }); go->AddComponent(new VisionCone()); { auto tex = new Sprite("Drone2_Bottom.png"); tex->SetColor(1.0f, 1.0f, 1.0f, 0.5f); go->AddComponent(tex); } go->transform.ScaleToSize(32.0f, 32.0f); go->SetActive(false); return go; } GameObject* UIFactory::CreateTurretButton(const Rect& area, ButtonType type, const ButtonCallback& callback) { auto go = new GameObject(); go->AddTags({ "UI", "BuildIcon" }); go->AddComponent(new Sprite(uthRS.LoadTexture("BlueBox.png"))); go->AddComponent(new Sprite(uthRS.LoadTexture("BasicDrone_Base.png"))); go->AddComponent(new Sprite(uthRS.LoadTexture("BasicDrone_Cannon.png"))); go->AddComponent(new Button(type, callback)); go->transform.SetPosition(area.position); go->transform.ScaleToSize(area.size); return go; } uth::GameObject* UIFactory::CreateGameoverScreen() { auto overlay = new GameObject(); overlay->AddTags({ "UI", "GameoverScreen", "Overlay" }); overlay->AddComponent(new Sprite(Vec4{ 0.0f, 0.0f, 0.0f, 0.5f }, Vec2{ 1, 1 }, "Overlay")); overlay->transform.ScaleToSize(uthEngine.GetWindow().GetCamera().GetSize()); auto picture = new GameObject(); picture->AddTags({ "UI", "GameoverScreen", "Picture" }); picture->AddComponent(new Sprite("GameOverText.png", "Picture")); picture->transform.ScaleToSize(0.5f, 0.2f); overlay->AddChild(picture); return overlay; }
/* * 题目:1006. 笨阶乘 * 链接:https://leetcode-cn.com/problems/clumsy-factorial/ * 知识点:栈、数学 */ class Solution { public: int clumsy(int N) { vector<int> nums(1, N); int i = 0; while (--N) { switch(i%4) { // 符号* case 0: nums.back() *= N; break; // 符号/ case 1: nums.back() /= N; break; // 符号+ case 2: nums.push_back(N); break; // 符号- case 3: nums.push_back(-N); break; } i++; } int ans = 0; for (auto num : nums) { ans += num; } return ans; } // 数学方法 // 题解链接:https://leetcode-cn.com/problems/clumsy-factorial/solution/ben-jie-cheng-by-leetcode-solution-deh2/ int clumsy_(int N) { if (N == 1) { return 1; } else if (N == 2) { return 2; } else if (N == 3) { return 6; } else if (N == 4) { return 7; } if (N % 4 == 0) { return N + 1; } else if (N % 4 <= 2) { return N + 2; } else { return N - 1; } } };
#pragma once #include "../../SDK/SDK.h" namespace Hooks { namespace FrameStageNotify { inline CHook Hook; using fn = void(__fastcall *)(void *, void *, ClientFrameStage_t); void __fastcall Func(void *ecx, void *edx, ClientFrameStage_t curStage); void Init(); } }
#include <iostream> #include <OpenNI.h> #include <opencv2/highgui.hpp> #include <opencv2/imgproc.hpp> #include <opencv2/objdetect.hpp> #include "FaceOffConfig.h" const int SAMPLE_READ_WAIT_TIMEOUT = 2000; // ms const float FACE_SIZE_RATIO = 0.25f; const float EYE_SIZE_RATIO = 0.25f; const float EYE_REGION_HEIGHT_PROPORTION = 0.6f; const cv::Scalar BLUE( 255, 0, 0 ); const cv::Scalar GREEN( 0, 255, 0 ); /** * Setup and initialise openNI * or fail */ int initializeDepthCamera( openni::Device& device, openni::VideoStream& depth, openni::VideoStream& colour ) { using namespace openni; Status rc = OpenNI::initialize(); if (rc != STATUS_OK) { std::cout << "Initialize failed: " << OpenNI::getExtendedError() << std::endl; return 1; } rc = device.open(ANY_DEVICE); if (rc != STATUS_OK) { std::cout << "Couldn't open device: " << OpenNI::getExtendedError() << std::endl; return 2; } if (device.getSensorInfo(SENSOR_DEPTH) != NULL) { rc = depth.create(device, SENSOR_DEPTH); if (rc == STATUS_OK) { rc = depth.start(); if (rc != STATUS_OK) { std::cout << "Couldn't start the depth stream: " << OpenNI::getExtendedError() << std::endl; } } else { std::cout << "Couldn't create depth stream: " << OpenNI::getExtendedError() << std::endl; } } if (device.getSensorInfo(SENSOR_COLOR) != NULL) { rc = colour.create(device, SENSOR_COLOR); if (rc == STATUS_OK) { rc = colour.start(); if (rc != STATUS_OK) { std::cout << "Couldn't start the colour stream: " << OpenNI::getExtendedError() << std::endl; } } else { std::cout << "Couldn't create colour stream: " << OpenNI::getExtendedError() << std::endl; } } return 0; } /** * Finish with the device, close down stream etc */ void finalizeDevice( openni::Device& device, openni::VideoStream& depth, openni::VideoStream& colour ) { depth.stop(); colour.stop(); depth.destroy(); colour.destroy(); device.close(); openni::OpenNI::shutdown(); } /** * Get a pair of frames; depth and RGB which are close together in time * @return -1 If no frame returned, 0 for depth and 1 for colour */ int getFrame( openni::VideoStream& depth, openni::VideoStream& colour, openni::VideoFrameRef& frame) { using namespace openni; int readyStream = -1; VideoStream * streams[] = { &depth, &colour }; Status rc = OpenNI::waitForAnyStream(streams, 2, &readyStream, SAMPLE_READ_WAIT_TIMEOUT); if (rc != STATUS_OK) { std::cout << "Wait failed! (timeout is " << SAMPLE_READ_WAIT_TIMEOUT << " ms): " << OpenNI::getExtendedError() << std::endl; } // Status was OK, we got a frame else { switch (readyStream) { case 0: // Depth depth.readFrame(&frame); break; case 1: // Colour colour.readFrame(&frame); break; default: std::cerr << "Unxpected stream: " << readyStream << std::endl; } } return readyStream; } /** * @return the path to the directory containing this executable file */ int getPathToExe( char * buffer, int buffer_length ) { char szTmp[32]; sprintf(szTmp, "/proc/%d/exe", getpid()); int bytes = MIN(readlink(szTmp, buffer, buffer_length), buffer_length - 1); if(bytes >= 0) buffer[bytes] = '\0'; // Now search from the end of the string to find the last file separator while( (--bytes > 0 ) && buffer[bytes] != '/'); if( buffer[bytes] == '/') { buffer[bytes] = '\0'; } else { bytes = strlen( buffer ); } return bytes; } /* * Load Haar classifiers for face and eyes */ bool loadHaarClassifiers( cv::CascadeClassifier& face_classifier, cv::CascadeClassifier& left_eye_classifier, cv::CascadeClassifier& right_eye_classifier ) { // Work out where this code is running from char exe_dir[1024]; getPathToExe( exe_dir, 1024 ); std::string base( exe_dir ); base += "/data"; // Classifiers should be in a data subdirectory std::cout << "Loading haar cascades from " << base << std::endl; bool loaded_ok = true; loaded_ok &= face_classifier.load( base + "/haarcascade_frontalface_default.xml" ); loaded_ok &= left_eye_classifier.load( base + "/haarcascade_lefteye_2splits.xml" ); loaded_ok &= right_eye_classifier.load( base + "/haarcascade_righteye_2splits.xml" ); return loaded_ok; } int main( int argc, char *argv[] ) { using namespace openni; std::cout << "FaceOff v" << VERSION_MAJOR << "." << VERSION_MINOR << std::endl; std::cout << "hit a key to quit" << std::endl; // Set up the capture device Device device; VideoStream colour, depth; if( initializeDepthCamera( device, depth, colour ) != 0 ) { return 1; } VideoFrameRef frame; // Load classifiers cv::CascadeClassifier faceClassifier, leftEyeClassifier, rightEyeClassifier; if( !loadHaarClassifiers( faceClassifier, leftEyeClassifier, rightEyeClassifier ) ) { std::cout << "Failed to load classfiers" << std::endl; return -1; } // Create a window to display RGB feed cv::namedWindow( "RGB" ); int numDepthFrames = 0; int numColourFrames= 0; while ( cv::waitKey(10) == -1 ) { int frameType = getFrame( depth, colour, frame ); // Depth frame if( frameType == 0 ) { // Register this to colour // Process frame numDepthFrames++; } else if ( frameType == 1 ) { // Grab pointer to data in appropriate format const RGB888Pixel* imageBuffer = (const openni::RGB888Pixel*)frame.getData(); // Create a Mat cv::Mat rgbImage; rgbImage.create( frame.getHeight(), frame.getWidth(), CV_8UC3 ); memcpy( rgbImage.data, imageBuffer, 3 * frame.getHeight()*frame.getWidth()*sizeof(uint8_t) ); // Manage BGR to RGB conversion cv::cvtColor( rgbImage, rgbImage, CV_BGR2RGB); // Make a grey version for face detection cv::Mat greyImage( frame.getHeight(), frame.getWidth(), CV_8UC1 ); cv::cvtColor( rgbImage, greyImage, CV_RGB2GRAY); // Find the face std::vector<cv::Rect> faces; cv::Size desiredSize( frame.getWidth() * FACE_SIZE_RATIO, frame.getHeight() * FACE_SIZE_RATIO ); faceClassifier.detectMultiScale( greyImage, faces, 1.1, 3, 0, desiredSize ); // Render if there is one if( faces.size() > 0 ) { // Render face box into image cv::rectangle( rgbImage, faces[0], BLUE, 3 ); // And find eyes cv::Rect eyeRegion( faces[0].x, faces[0].y, faces[0].width, faces[0].height * EYE_REGION_HEIGHT_PROPORTION ); cv::Mat eyeROI = greyImage( eyeRegion ); cv::Size desiredSize( eyeRegion.width * EYE_SIZE_RATIO, eyeRegion.width * EYE_SIZE_RATIO ); std::vector<cv::Rect> leftEyes; leftEyeClassifier.detectMultiScale( eyeROI, leftEyes, 1.1, 2, 0, desiredSize ); if( leftEyes.size() > 0 ) { leftEyes[0].x += faces[0].x; leftEyes[0].y += faces[0].y; cv::rectangle( rgbImage, leftEyes[0], GREEN, 2 ); } std::vector<cv::Rect> rightEyes; rightEyeClassifier.detectMultiScale( eyeROI, rightEyes, 1.1, 2, 0, desiredSize ); if( rightEyes.size() > 0 ) { rightEyes[0].x += faces[0].x; rightEyes[0].y += faces[0].y; cv::rectangle( rgbImage, rightEyes[0], GREEN, 2 ); } } // Render cv::imshow( "RGB", rgbImage ); numColourFrames++; } std::cout << "\rDepth frames : " << numDepthFrames << " Colour frames : " << numColourFrames << std::flush; } std::cout << std::endl; cv::destroyWindow( "RGB" ); // Shutdown the device finalizeDevice( device, depth, colour ); return 0; }
#include"stdio.h" #include"conio.h" void main(void){ clrscr(); int i,b; int array[5]; int len=5; for(i=0; i<len; i++){ printf("Enter Values: "); scanf("%d",&array[i]); } for(i=0; i<len; i++) printf("%d,",array[i]); printf("\n\n\nEnter delete element: "); scanf("%d",&b); for(i=0; i<len; i++) if(array[i]==b){ for(int x=i; x<len-1; x++) array[x]=array[x+1]; len--; } for(i=0; i<len; i++) printf("%d\n",array[i]); getch(); }// end of main
#ifndef __POLYGON_H__ #define __POLYGON_H__ // Library Includes #include <windows.h> #include <windowsx.h> #include "shape.h" class CPolygon : public IShape { public: CPolygon(); CPolygon(EBRUSHSTYLE _iBrushStyle, int _iHatchStyle, COLORREF _FillColor, int _iPenStyle, int _iPenWidth, COLORREF _iPenColor); virtual ~CPolygon(); virtual void Draw(HDC _hdc); void AddPoint(POINT _p); int GetPoints() const; private: COLORREF m_Color; POINT* m_pPointList; int m_nPoints; }; #endif //__POLYGON_H__
#pragma once #include "Ball.h" using namespace std; class Bludger : public Ball { public: int id; Bludger(int i); ~Bludger(); void Run(); void Collide(vector<pair<Point3, Point2>>); }; #define BLUDGER_ID 6 #define BLUDGER_INTERVAL_RADIUS 60 #define BLUDGER_INIT_DISTANCE 0.4 #define BLUDGER_SPEED 0.01
#include <iostream> #include <vector> #include <cmath> const int MAX_D = 16; std::vector<std::vector<int>> link(50001); int level[50001], parent[50001][MAX_D]; void dfs(int idx, int lev) { for(auto next : link[idx]) { if(level[next] == 0) { level[next] = lev + 1; parent[next][0] = idx; dfs(next, lev + 1); } } } int main() { std::cin.sync_with_stdio(false); std::cin.tie(NULL); int n, m; std::cin >> n; for(int i = 0; i < n - 1; i++) { int a, b; std::cin >> a >> b; link[a].push_back(b); link[b].push_back(a); } level[1] = 1; dfs(1, 1); for(int j = 0; j < MAX_D - 1; j++) { for(int i = 1; i <= n; i++) { if(parent[i][j] > 0) { parent[i][j + 1] = parent[parent[i][j]][j]; } } } std::cin >> m; while(m--) { int x, y; std::cin >> x >> y; if(level[x] > level[y]) { std::swap(x, y); } int diff = level[y] - level[x]; for(int i = 0; diff > 0; i++) { if(diff % 2) { y = parent[y][i]; } diff /= 2; } if(x != y) { for(int i = MAX_D - 1; i >= 0; i--) { if(parent[x][i] > 0 && parent[x][i] != parent[y][i]) { x = parent[x][i]; y = parent[y][i]; } } x = parent[x][0]; } std::cout << x << '\n'; } return 0; }
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- ** ** Copyright (C) 1995-2008 Opera Software AS. All rights reserved. ** ** This file is part of the Opera web browser. It may not be distributed ** under any circumstances. ** */ #ifndef _JUSTLOAD_TESTMAN_H_ #define _JUSTLOAD_TESTMAN_H_ #if defined(SELFTEST) #include "modules/network_selftest/urldoctestman.h" class JustLoad_Tester : public URL_DocSelfTest_Item { protected: BOOL header_loaded; public: JustLoad_Tester() : header_loaded(FALSE) {}; JustLoad_Tester(URL &a_url, URL &ref, BOOL unique=TRUE) : URL_DocSelfTest_Item(a_url, ref, unique), header_loaded(FALSE) {}; virtual ~JustLoad_Tester(){} OP_STATUS Construct(){return url.IsValid() ? OpStatus::OK : OpStatus::ERR;} OP_STATUS Construct(URL &a_url, URL &ref, BOOL unique=TRUE); OP_STATUS Construct(const OpStringC8 &source_url, URL &ref, BOOL unique=TRUE); OP_STATUS Construct(const OpStringC &source_url, URL &ref, BOOL unique=TRUE); virtual BOOL Verify_function(URL_DocSelfTest_Event event, Str::LocaleString status_code=Str::NOT_A_STRING); }; #endif #endif // _JUSTLOAD_TESTMAN_H_
#include <conio.h> #include <stdlib.h> #include <stdio.h> #include <time.h> #include <string.h> #include <math.h> #include <locale.h> #include <ctype.h> int a,i; int main() { int num[10]; printf("Insira 10 numeros:\n"); for( a=0; a<10; a++) { scanf("%i", &num[a]); } printf("Os numeros inseridos foram:\n"); for( i=9; i>= 0; i--) { printf(" %i \n", num[i]); } return 0; }
/****************************************************************************** * * * Copyright 2020 Jan Henrik Weinstock * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * ******************************************************************************/ #include "testing.h" test_base::test_base(const sc_module_name& nm): component(nm) { SC_HAS_PROCESS(test_base); SC_THREAD(run); } test_base::~test_base() { finalize_test(); } void test_base::run() { wait(SC_ZERO_TIME); run_test(); sc_stop(); } void test_base::finalize_test() { ASSERT_EQ(sc_core::sc_get_status(), sc_core::SC_STOPPED) << "simulation incomplete"; } void test_base::before_end_of_elaboration() { if (!CLOCK.is_bound()) CLOCK.stub(100 * MHz); if (!RESET.is_bound()) RESET.stub(); } vector<string> args; int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); for (int i = 0; i < argc; i++) args.push_back(argv[i]); return RUN_ALL_TESTS(); } int sc_main(int argc, char** argv) { EXPECT_TRUE(false) << "sc_main called"; return EXIT_FAILURE; }
/** @file * IPRT - C++ Resource Management. */ /* * Copyright (C) 2008-2011 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. * * The contents of this file may alternatively be used under the terms * of the Common Development and Distribution License Version 1.0 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the * VirtualBox OSE distribution, in which case the provisions of the * CDDL are applicable instead of those of the GPL. * * You may elect to license modified versions of this file under the * terms and conditions of either the GPL or the CDDL or both. */ #ifndef ___iprt_autores_h #define ___iprt_autores_h #include <iprt/types.h> #include <iprt/assert.h> #include <iprt/cpp/utils.h> /** @defgroup grp_rt_cpp_autores C++ Resource Management * @ingroup grp_rt_cpp * @{ */ /** * A callable class template which returns the correct value against which an * IPRT type must be compared to see if it is invalid. * * @warning This template *must* be specialised for the types it is to work with. */ template <class T> inline T RTAutoResNil(void) { AssertFatalMsgFailed(("Unspecialized template!\n")); return (T)0; } /** Specialisation of RTAutoResNil for RTFILE */ template <> inline RTFILE RTAutoResNil(void) { return NIL_RTFILE; } /** * A function template which calls the correct destructor for an IPRT type. * * @warning This template *must* be specialised for the types it is to work with. */ template <class T> inline void RTAutoResDestruct(T a_h) { AssertFatalMsgFailed(("Unspecialized template!\n")); NOREF(a_h); } /** * An auto pointer-type class for resources which take a C-style destructor * (RTMemFree() or equivalent). * * The idea of this class is to manage resources which the current code is * responsible for freeing. By wrapping the resource in an RTCAutoRes, you * ensure that the resource will be freed when you leave the scope in which * the RTCAutoRes is defined, unless you explicitly release the resource. * * A typical use case is when a function is allocating a number of resources. * If any single allocation fails then all other resources must be freed. If * all allocations succeed, then the resources should be returned to the * caller. By placing all allocated resources in RTCAutoRes containers, you * ensure that they will be freed on failure, and only have to take care of * releasing them when you return them. * * @param T The type of the resource. * @param Destruct The function to be used to free the resource. * This parameter must be supplied if there is no * specialisation of RTAutoDestruct available for @a T. * @param NilRes The function returning the NIL value for T. Required. * This parameter must be supplied if there is no * specialisation of RTAutoResNil available for @a T. * * @note The class can not be initialised directly using assignment, due * to the lack of a copy constructor. This is intentional. */ template <class T, void Destruct(T) = RTAutoResDestruct<T>, T NilRes(void) = RTAutoResNil<T> > class RTCAutoRes : public RTCNonCopyable { protected: /** The resource handle. */ T m_hRes; public: /** * Constructor * * @param a_hRes The handle to resource to manage. Defaults to NIL. */ RTCAutoRes(T a_hRes = NilRes()) : m_hRes(a_hRes) { } /** * Destructor. * * This destroys any resource currently managed by the object. */ ~RTCAutoRes() { if (m_hRes != NilRes()) Destruct(m_hRes); } /** * Assignment from a value. * * This destroys any resource currently managed by the object * before taking on the new one. * * @param a_hRes The handle to the new resource. */ RTCAutoRes &operator=(T a_hRes) { if (m_hRes != NilRes()) Destruct(m_hRes); m_hRes = a_hRes; return *this; } /** * Checks if the resource handle is NIL or not. */ bool operator!() { return m_hRes == NilRes(); } /** * Give up ownership the current resource, handing it to the caller. * * @returns The current resource handle. * * @note Nothing happens to the resource when the object goes out of scope. */ T release(void) { T Tmp = m_hRes; m_hRes = NilRes(); return Tmp; } /** * Deletes the current resources. * * @param a_hRes Handle to a new resource to manage. Defaults to NIL. */ void reset(T a_hRes = NilRes()) { if (a_hRes != m_hRes) { if (m_hRes != NilRes()) Destruct(m_hRes); m_hRes = a_hRes; } } /** * Get the raw resource handle. * * Typically used passing the handle to some IPRT function while * the object remains in scope. * * @returns The raw resource handle. */ T get(void) { return m_hRes; } }; /** @} */ /* include after template definition */ #include <iprt/mem.h> #endif
#include "msg_0x09_respawn_stc.h" namespace MC { namespace Protocol { namespace Msg { Respawn::Respawn() { _pf_packetId = static_cast<int8_t>(0x09); _pf_initialized = false; } Respawn::Respawn(int32_t _dimension, int8_t _difficulty, int8_t _gameMode, int16_t _worldHeight, const String16& _levelType) : _pf_dimension(_dimension) , _pf_difficulty(_difficulty) , _pf_gameMode(_gameMode) , _pf_worldHeight(_worldHeight) , _pf_levelType(_levelType) { _pf_packetId = static_cast<int8_t>(0x09); _pf_initialized = true; } size_t Respawn::serialize(Buffer& _dst, size_t _offset) { _pm_checkInit(); if(_offset == 0) _dst.clear(); _offset = WriteInt8(_dst, _offset, _pf_packetId); _offset = WriteInt32(_dst, _offset, _pf_dimension); _offset = WriteInt8(_dst, _offset, _pf_difficulty); _offset = WriteInt8(_dst, _offset, _pf_gameMode); _offset = WriteInt16(_dst, _offset, _pf_worldHeight); _offset = WriteString16(_dst, _offset, _pf_levelType); return _offset; } size_t Respawn::deserialize(const Buffer& _src, size_t _offset) { _offset = _pm_checkPacketId(_src, _offset); _offset = ReadInt32(_src, _offset, _pf_dimension); _offset = ReadInt8(_src, _offset, _pf_difficulty); _offset = ReadInt8(_src, _offset, _pf_gameMode); _offset = ReadInt16(_src, _offset, _pf_worldHeight); _offset = ReadString16(_src, _offset, _pf_levelType); _pf_initialized = true; return _offset; } int32_t Respawn::getDimension() const { return _pf_dimension; } int8_t Respawn::getDifficulty() const { return _pf_difficulty; } int8_t Respawn::getGameMode() const { return _pf_gameMode; } int16_t Respawn::getWorldHeight() const { return _pf_worldHeight; } const String16& Respawn::getLevelType() const { return _pf_levelType; } void Respawn::setDimension(int32_t _val) { _pf_dimension = _val; } void Respawn::setDifficulty(int8_t _val) { _pf_difficulty = _val; } void Respawn::setGameMode(int8_t _val) { _pf_gameMode = _val; } void Respawn::setWorldHeight(int16_t _val) { _pf_worldHeight = _val; } void Respawn::setLevelType(const String16& _val) { _pf_levelType = _val; } } // namespace Msg } // namespace Protocol } // namespace MC
#include <bits/stdc++.h> #define ll long long #define pf printf #define sfi(a) scanf("%d",&a); #define sfii(a,b) scanf("%d %d",&a,&b); #define INF 100000 //10e9 using namespace std; int ar[50005]; struct node { int rtlmax,ltrmax,ovmax,sum; node() { rtlmax = -INF; ltrmax = -INF; ovmax = -INF; sum = -INF; } }; node tree[6*50005]; void build(int root,int b,int e,int x,int y) { if(x!=0 && b>x || e<x) { return; } if(x!=0 && b==e && b==x) { tree[root].ltrmax = y; tree[root].rtlmax = y; tree[root].ovmax = y; tree[root].sum = y; return; } if(x==0 && b==e) { tree[root].ltrmax = ar[b]; tree[root].rtlmax = ar[b]; tree[root].ovmax = ar[b]; tree[root].sum = ar[b]; return; } int mid = (b+e)/2; int lc = root*2; int rc = lc+1; build(lc,b,mid,x,y); build(rc,mid+1,e,x,y); tree[root].sum = tree[lc].sum + tree[rc].sum; tree[root].ltrmax = tree[lc].ltrmax; if(tree[lc].ltrmax==tree[lc].rtlmax) { tree[root].ltrmax = max( tree[root].ltrmax,tree[lc].ltrmax + tree[rc].ltrmax); } tree[root].ltrmax = max(tree[root].ltrmax, tree[lc].sum + tree[rc].ltrmax); tree[root].rtlmax = tree[rc].rtlmax; if(tree[rc].rtlmax==tree[rc].ltrmax) { tree[root].rtlmax = max( tree[root].rtlmax,tree[rc].rtlmax + tree[lc].rtlmax); } tree[root].rtlmax = max( tree[root].rtlmax, tree[rc].sum + tree[lc].rtlmax); tree[root].ovmax = max({tree[lc].ltrmax, tree[lc].rtlmax, tree[lc].ovmax, tree[rc].ltrmax, tree[rc].rtlmax, tree[rc].ovmax, tree[lc].rtlmax+ tree[rc].ltrmax, tree[lc].sum, tree[rc].sum, tree[root].sum, tree[root].ltrmax, tree[root].rtlmax }); } node query(int root,int b,int e,int i,int j) { if(b>j || e<i) { node dummy; //cout<<dummy.ltrmax<<endl; return dummy; } if(b>=i && e<=j) { return tree[root]; } int mid = (b+e)/2; int lc = root*2; int rc = lc+1; node treelc = query(lc,b,mid,i,j); node treerc = query(rc,mid+1,e,i,j); node treeroot; treeroot.sum = treelc.sum + treerc.sum; treeroot.ltrmax = treelc.ltrmax; if(treelc.ltrmax==treelc.rtlmax) { treeroot.ltrmax = max( treeroot.ltrmax,treelc.ltrmax + treerc.ltrmax); } treeroot.ltrmax = max(treeroot.ltrmax, treelc.sum + treerc.ltrmax); treeroot.rtlmax = treerc.rtlmax; if(treerc.rtlmax==treerc.ltrmax) { treeroot.rtlmax = max( treeroot.rtlmax,treerc.rtlmax + treelc.rtlmax); } treeroot.rtlmax = max( treeroot.rtlmax, treerc.sum + treelc.rtlmax); treeroot.ovmax = max({treelc.ltrmax, treelc.rtlmax, treelc.ovmax, treerc.ltrmax, treerc.rtlmax, treerc.ovmax, treelc.rtlmax + treerc.ltrmax, treelc.sum, treerc.sum, treeroot.sum, treeroot.ltrmax, treeroot.rtlmax }); return treeroot; } int main() { int n; sfi(n); for(int i=1; i<=n; i++) { sfi(ar[i]); } build(1,1,n,0,0); int q; sfi(q); while(q--) { int cmd; sfi(cmd); int x,y; sfii(x,y); if(cmd==1) { node fans = query(1,1,n,x,y); pf("%d\n",fans.ovmax); } else { build(1,1,n,x,y); } } return 0; }
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- ** ** Copyright (C) 2009 Opera Software AS. All rights reserved. ** ** This file is part of the Opera web browser. It may not be distributed ** under any circumstances. */ /** * @file OpenSSLSocket.h * * SSL-capable socket. * * @author Alexei Khlebnikov <alexeik@opera.com> * */ #ifndef OPENSSL_SOCKET_H #define OPENSSL_SOCKET_H #ifdef EXTERNAL_SSL_OPENSSL_IMPLEMENTATION #include "modules/externalssl/src/OpSSLSocket.h" #include "modules/libopeay/openssl/cryptlib.h" #include "modules/libopeay/openssl/ssl.h" #define OPENSSL_SOCKET_BUFFER_SIZE (16 * 1024) class OpenSSLSocket: public OpSSLSocket, public OpSocketListener, public MessageObject { public: OpenSSLSocket(OpSocketListener* listener, BOOL secure = FALSE); OP_STATUS Init(); virtual ~OpenSSLSocket(); public: // OpSocket methods virtual OP_STATUS Connect(OpSocketAddress* socket_address); virtual OP_STATUS Send(const void* data, UINT length); virtual OP_STATUS Recv(void* buffer, UINT length, UINT* bytes_received); virtual void Close(); virtual OP_STATUS GetSocketAddress(OpSocketAddress* socket_address); virtual void SetListener(OpSocketListener* listener) { m_listener = listener; } #ifdef OPSOCKET_PAUSE_DOWNLOAD // OpSocket pause/resume methods virtual OP_STATUS PauseRecv(); virtual OP_STATUS ContinueRecv(); #endif // OPSOCKET_PAUSE_DOWNLOAD #ifdef OPSOCKET_OPTIONS // OpSocket option methods virtual OP_STATUS SetSocketOption(OpSocketBoolOption option, BOOL value); virtual OP_STATUS GetSocketOption(OpSocketBoolOption option, BOOL& out_value); #endif // OPSOCKET_OPTIONS #ifdef SOCKET_LISTEN_SUPPORT // OpSocket server methods virtual OP_STATUS Listen(OpSocketAddress* socket_address, int queue_size) { Unimplemented(); return OpStatus::ERR_NOT_SUPPORTED; } virtual OP_STATUS Accept(OpSocket* socket) { Unimplemented(); return OpStatus::ERR_NOT_SUPPORTED; } #endif // SOCKET_LISTEN_SUPPORT // OpSocket external SSL methods virtual OP_STATUS UpgradeToSecure(); virtual OP_STATUS SetSecureCiphers(const cipherentry_st* ciphers, UINT cipher_count); virtual OP_STATUS AcceptInsecureCertificate(OpCertificate* cert); virtual OP_STATUS GetCurrentCipher(cipherentry_st* used_cipher, BOOL* tls_v1_used, UINT32* pk_keysize); virtual OP_STATUS SetServerName(const uni_char* server_name); virtual OpCertificate* ExtractCertificate(); virtual OpAutoVector<OpCertificate>* ExtractCertificateChain(); virtual int GetSSLConnectErrors() { return m_ssl_cert_errors; } public: // OpSocketListener methods virtual void OnSocketConnected(OpSocket* socket); virtual void OnSocketDataReady(OpSocket* socket); virtual void OnSocketDataSent(OpSocket* socket, UINT bytes_sent); virtual void OnSocketClosed(OpSocket* socket); virtual void OnSocketConnectError(OpSocket* socket, OpSocket::Error error); virtual void OnSocketReceiveError(OpSocket* socket, OpSocket::Error error); virtual void OnSocketSendError(OpSocket* socket, OpSocket::Error error); virtual void OnSocketCloseError(OpSocket* socket, OpSocket::Error error); #ifdef SOCKET_LISTEN_SUPPORT virtual void OnSocketConnectionRequest(OpSocket* socket) { Unimplemented(); } virtual void OnSocketListenError(OpSocket* socket, OpSocket::Error error) { Unimplemented(); } #endif // SOCKET_LISTEN_SUPPORT public: // MessageObject methods virtual void HandleCallback(OpMessage msg, MH_PARAM_1 par1, MH_PARAM_2 par2); private: MH_PARAM_1 Id() const { return reinterpret_cast <MH_PARAM_1> (this); } OP_STATUS HandleOpenSSLReturnCode(int status); OP_STATUS HandleOpenSSLPositiveReturnCode(int status); OP_STATUS HandleOpenSSLNegativeReturnCode(int status, int err); void HandleOpenSSLBIOs(); static void PrepareBuffer(char* buf, char* buf_pos, int buf_len, char*& buf_end, char*& buf_free_pos, int& buf_free_len); void HandleOpenSSLRBIO(); void HandleOpenSSLWBIO(); void HandleOpenSSLNonBlocking(); void UpdatePeerCert(); void UpdatePeerCertVerification(); void ClearSSL(); private: // Platform socket, listener OpSocket* m_socket; OpSocketListener* m_listener; // Opera SSL related stuff bool m_secure; const cipherentry_st* m_ciphers; UINT m_cipher_count; OpString m_server_name; int m_ssl_cert_errors; // OpenSSL related stuff // One SSL_CTX instance per program is sufficient. Should be moved out of the class. SSL_CTX* m_ssl_ctx; BIO* m_rbio; BIO* m_wbio; SSL* m_ssl; X509* m_peer_cert; private: // States enum SSLState { SSL_STATE_NOSSL, SSL_STATE_HANDSHAKING, SSL_STATE_ASKING_USER, SSL_STATE_CONNECTED, SSL_STATE_READING, SSL_STATE_WRITING, SSL_STATE_SHUTTING_DOWN, // Unused state SSL_STATE_LAST }; enum SSLState m_ssl_state; bool m_socket_data_ready; // Socket buffers // Buffer for reading from m_socket and writing to m_wbio char m_rbuf[OPENSSL_SOCKET_BUFFER_SIZE]; /* ARRAY OK 2009-09-04 alexeik */ // Buffer for writing to m_socket and reading from m_wbio char m_wbuf[OPENSSL_SOCKET_BUFFER_SIZE]; /* ARRAY OK 2009-09-04 alexeik */ // Current positions of useful data in buffers char* m_rbuf_pos; char* m_wbuf_pos; // Current lengths of useful data in buffers int m_rbuf_len; int m_wbuf_len; private: void Unimplemented(); }; #endif // EXTERNAL_SSL_OPENSSL_IMPLEMENTATION #endif // OPENSSL_SOCKET_H
int resist=A1; float port, Vm, Rm; void setup() { // put your setup code here, to run once: Serial.begin (9600); } void loop() { // put your main code here, to run repeatedly: port=analogRead(resist); Vm=(port*5/1023); Rm=(10*(5-Vm)/Vm); Serial.println(Rm); }
#ifndef __MACHINE__ #define __MACHINE__ #include "Controller.h" #include "OnOffController.h" class Machine { public: // コンストラクタ explicit Machine(Controller& controller_) : controller(controller_){}; // キャリブレーション void calibration(); // 走行 void run(); // ゲッター int getBlack() { return black; } int getWhite() { return white; } private: int setBrightness(); // 色の光を決定する Controller controller; OnOffController onOffController; int black; // 黒のBrightness int white; // 白のBrightness }; #endif
//############################################################################### // INTRODUCCION: Texture.h //------------------------------------------------------------------------------ // Este codigo nos proporciona la estructura para crear una textura a partir // de un fichero de imagen. // // PROGRESO DEL CODIGO //------------------------------------------------------------------------------ // Fecha Editor Descripcion //------------------------------------------------------------------------------ // 2012.03.20 Helio Tejedor Codigo creado //############################################################################## #pragma once #include "MyGL.h" #include <string> class Texture { public: Texture(const std::string& filename); virtual ~Texture(); public: //Para crear y cargar la textura a partir del fichero void load(); //Para eliminar la textura void unload(); //Para enlazar la textura al objeto que este activo void bind(); private: const std::string m_filename; bool m_loaded; GLuint m_textureId; };
#ifndef CCC_ITEM_HPP #define CCC_ITEM_HPP #include <QObject> // Include ui_view.h in source and header #include <ccc/ui_view.h> namespace ccc { class Item : public QObject { Q_OBJECT Q_SLOT void go(); }; } #endif
#include "modifierfinance.h" #include "ui_modifierfinance.h" #include <QPalette> #include <QDesktopWidget> #include <QtGui> #include"menuprincipale.h" modifierfinance::modifierfinance(QWidget *parent) : QDialog(parent), ui(new Ui::modifierfinance) { ui->setupUi(this); //QPixmap pix("C:/Users/MohamedAnes/Desktop/QTT/gestion de la clientele/clientele/coevercoaching.jpg"); //pix.scaled ( width, height, Qt::IgnoreAspectRatio, Qt::FastTransformation ) // ui->Lpicture->setPixmap(pix); //Using QPalette you can set background image as follows. QPalette p = palette(); //Load image to QPixmap, Give full path of image QPixmap pixmap1("C:/Users/ASUS/Desktop/projet/coevercoaching.jpg"); //For emulator C: is ..\epoc32\winscw\c so image must be at that location //resize image if it is larger than screen size. QDesktopWidget* desktopWidget = QApplication::desktop(); QRect rect = desktopWidget->availableGeometry(); QSize size(rect.width() , rect.height()); //resize as per your requirement.. QPixmap pixmap(pixmap1.scaled(640,480)); p.setBrush(QPalette::Background, pixmap); setPalette(p); } modifierfinance::~modifierfinance() { delete ui; } void modifierfinance::on_MCprecedentPB_clicked() { this->hide(); menuprincipale * dlg = new menuprincipale (); dlg->show(); }
// // Created by 송지원 on 2020-05-17. // #include <iostream> #include <stack> #include <utility> using namespace std; #define X first #define Y second int board[502][502] = {...}; bool vis[502][502]; int n=7, m=10; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int main() { ios::sync_with_stdio(0); cin.tie(0); stack<pair<int,int>> S; vis[0][0] = 1; S.push({0,0}); while (!S.empty()) { pair<int, int> cur = S.top(); S.pop(); cout << "(" << cur.X << ", " << cur.Y << ") -> "; for (int dir=0; dir<4; dir++) { int nx = cur.X + dx[dir]; int ny = cur.Y + dy[dir]; if (nx<0 || nx>=n || ny<0 || ny>=m) continue; if (vis[nx][ny] || board[nx][ny] != 1) continue; vis[nx][ny] = 1; S.push({nx, ny}); } } }
#ifndef MODEL_H #define MODEL_H #include <vector> #include "datatypes.h" #include "batch_method_t.h" #include "model_status_t.h" #include "optimizer.h" #include "logger.h" #include "random_engine.h" class Model { private: /* Single sample variables */ float64_t inp; float64_t out; float64_t weight; float64_t bias; float64_t pred_out; float64_t loss; float64_t dL_dw; float64_t dL_db; /* Single batch variables */ float64_t batch_loss; float64_t batch_dL_dw; float64_t batch_dL_db; uint32_t sample_num; uint32_t batch_num; uint32_t batch_size; uint32_t total_epochs; uint32_t epoch; RandomEngine random_engine; Optimizer optimizer; Logger logger; Model_Status_T status; boolean_t schuffle_input; public: Model(); void init(const uint32_t in_epochs, const Batch_Method_T batch_method, const boolean_t in_schuffle_input); void setInOut(const float64_t in_inp, const float64_t in_out); void forwardProp(void); void findLoss(void); void backwardProp(void); void updateWeights(void); void checkWeights(void); void run(std::vector<float64_t> &inp_vec, std::vector<float64_t> &out_vec); float64_t getWeight(void); float64_t getBias(void); uint32_t getTotalEpochs(void); uint32_t getEpochNum(void); Optimizer* getOptimizer(void); Logger* getLogger(void); }; #endif
/** * @file 3735.cc * @author FAN Kai (fankai@net.pku.edu.cn), Peking University * @date May 22 04:27:25 PM CST 2009 */ #include <iostream> #include <algorithm> #include <cassert> #include <vector> using namespace std; class Matrix { public: Matrix(int row, int col) { this->row = row; this->col = col; dat.resize(row*col); } void print() { for (int i = 0; i < row; ++i) { for (int j = 0; j < col; ++j) { cout <<e(i,j) <<"\t"; } cout <<endl; } } inline long long & e(int x, int y) { //cout <<"row="<<row <<" col=" <<col <<" x=" <<x <<" y=" <<y <<endl; //assert(x >= 0 && x < row); //assert(y >= 0 && y < col); return dat[x*col+y]; } Matrix operator*(Matrix &r) { assert(col == r.row); Matrix m(row, r.col); for (int i = 0; i < row; ++i) { for (int j = 0; j < r.col; ++j) { for (int k = 0; k < col; ++k) { if (e(i,k)>0 && r.e(k,j)>0) m.e(i,j) += e(i,k)*r.e(k,j); } } } return m; } Matrix power(int n) { assert(row == col); if (n == 0) { return Matrix::unit(row); } Matrix t = power(n/2); Matrix tt = t*t; if (n % 2 == 1) return (*this)*tt; else return tt; } static Matrix unit(int num) { Matrix m(num, num); for (int i = 0; i < num; ++i) m.e(i,i) = 1; return m; } private: int row, col; vector<long long> dat; }; void test() { Matrix m = Matrix::unit(4); Matrix ma = Matrix::unit(4); m.e(0,1) = 4; m.e(3,2) = 44; ma.e(0,3) = 3; ma.e(2,1) = 9; Matrix mm = m*ma; m.print(); ma.print(); mm.print(); mm.power(2).print(); //mm.power(3).print(); Matrix mc = Matrix::unit(3); mc.e(0,0) = 2; mc.power(3).print(); } int main() { //test(); return 0; int n, m, k; while (true) { cin >>n >>m >>k; if (n == 0) break; Matrix ma(1, n+1); ma.e(0, n) = 1; Matrix mo(n+1, n+1); for (int i = 0; i <=n; ++i) mo.e(i, i) = 1; for (int i = 0; i < k; ++i) { char c; int a, b; cin >>c >>a; //cout <<c <<a <<endl; if (c == 'g') { mo.e(n, a-1) ++; } else if (c == 'e') { for (int j = 0; j <= n; ++j) mo.e(j, a-1) = 0; } else { cin >>b; for (int j = 0; j <= n; ++j) swap(mo.e(j, a-1), mo.e(j, b-1)); } //mo.print(); } //cout <<"mo" <<endl;mo.print(); mo = mo.power(m); //cout <<"mo^" <<m <<endl;mo.print(); //cout <<"ma" <<endl; ma.print(); Matrix mm = ma*mo; //cout <<"ma*mo" <<endl; mm.print(); for (int i = 0; i < n; ++i) cout <<mm.e(0, i) <<" " ; cout <<endl; } return 0; }
#include <iostream> using namespace std; int main() { int res = 2; int tra; int fib1 = 1; int fib2 = 2; int temp; cout<<fib1<<"\n"<<fib2<<"\n"; while(fib2 < 4000000){ temp = fib2; fib2 = fib1 +fib2; fib1 = temp; if(fib2%2==0) res = res + fib2; cout<<fib2<<"\n"; } cout<<res<<"\n"; return 0; }
/* * @lc app=leetcode.cn id=110 lang=cpp * * [110] 平衡二叉树 */ // @lc code=start /** * Definition for a binary tree node. */ #include<iostream> #include<vector> #include<algorithm> using namespace std; // struct TreeNode { // int val; // TreeNode *left; // TreeNode *right; // TreeNode(int x) : val(x), left(NULL), right(NULL) {} // }; class Solution { public: bool isBalanced(TreeNode* root) { if(root==NULL)return true; int lh = height(root->left); int rh = height(root->right); return (abs(lh-rh)<=1)&&isBalanced(root->left) && isBalanced(root->right); } int height(TreeNode* root){ if(root==NULL)return 0; int lh = height(root->left); int rh = height(root->right); return max(lh,rh) + 1; } }; // @lc code=end
#ifndef MODELEXCEPTION_HPP #define MODELEXCEPTION_HPP #include <stdexcept> class ModelException : public std::exception { public: const char * what() const noexcept override; }; class ModelBoxNotOpenException : public ModelException { public: const char * what() const noexcept override; }; class ModelBoxNotClosedException : public ModelException { public: const char * what() const noexcept override; }; class ModelBoxPathNotSetException : public ModelException { public: const char * what() const noexcept override; }; class ModelFileNotAvailableException : public ModelException { public: const char * what() const noexcept override; }; class ModelBadTypeException : public ModelException { public: const char * what() const noexcept override; }; class ModelEmptyBoxException : public ModelException { public: const char * what() const noexcept override; }; class ModelDuplicateKeyException : public ModelException { public: const char * what() const noexcept override; }; class ModelArticleNotFoundException : public ModelException { public: const char * what() const noexcept override; }; #endif // MODELEXCEPTION_HPP
#include <iostream> #include <string> #include "BITMAP.h" using namespace std; enum { to8bits, to4bits, to24bits, toGray, toBlackwhite }; void loadInfo(char *name) { FILE *fp; BITMAPFILEHEADER bf; BITMAPINFOHEADER bi; if ((fp = fopen(name, "rb")) == NULL) { cout << "Open file failed." << endl; } fread(&bf, sizeof(bf), 1, fp); printf("bfType --> %c\n", bf.bfType); printf("bfSize --> %d\n", bf.bfSize); printf("bfOffsets --> %d\n", bf.bfOffBits); fread(&bi, sizeof(bi), 1, fp); printf("biSize: %d\n", bi.biSize); printf("biWidth: %d\n", bi.biWidth); //位图宽度 printf("biHeight:%d\n", bi.biHeight); //位图高度 printf("biPlanes:%d\n", bi.biPlanes); //颜色位面数,总为1 printf("biBitCount:%d\n", bi.biBitCount); //每象数颜色位(1,2,4,8,24) printf("bmCompression: %d\n", bi.bmCompression); } RGBQUAD rgbquad[256] = {//用于转化为256色的调色板 0, 0, 0, 0, 0, 0, 128, 0, 0, 128, 0, 0, 0, 128, 128, 0, 128, 0, 0, 0, 128, 0, 128, 0, 128, 128, 0, 0, 192, 192, 192, 0, 192, 220, 192, 0, 240, 202, 166, 0, 0, 32, 64, 0, 0, 32, 96, 0, 0, 32, 128, 0, 0, 32, 160, 0, 0, 32, 192, 0, 0, 32, 224, 0, 0, 64, 0, 0, 0, 64, 32, 0, 0, 64, 64, 0, 0, 64, 96, 0, 0, 64, 128, 0, 0, 64, 160, 0, 0, 64, 192, 0, 0, 64, 224, 0, 0, 96, 0, 0, 0, 96, 32, 0, 0, 96, 64, 0, 0, 96, 96, 0, 0, 96, 128, 0, 0, 96, 160, 0, 0, 96, 192, 0, 0, 96, 224, 0, 0, 128, 0, 0, 0, 128, 32, 0, 0, 128, 64, 0, 0, 128, 96, 0, 0, 128, 128, 0, 0, 128, 160, 0, 0, 128, 192, 0, 0, 128, 224, 0, 0, 160, 0, 0, 0, 160, 32, 0, 0, 160, 64, 0, 0, 160, 96, 0, 0, 160, 128, 0, 0, 160, 160, 0, 0, 160, 192, 0, 0, 160, 224, 0, 0, 192, 0, 0, 0, 192, 32, 0, 0, 192, 64, 0, 0, 192, 96, 0, 0, 192, 128, 0, 0, 192, 160, 0, 0, 192, 192, 0, 0, 192, 224, 0, 0, 224, 0, 0, 0, 224, 32, 0, 0, 224, 64, 0, 0, 224, 96, 0, 0, 224, 128, 0, 0, 224, 160, 0, 0, 224, 192, 0, 0, 224, 224, 0, 64, 0, 0, 0, 64, 0, 32, 0, 64, 0, 64, 0, 64, 0, 96, 0, 64, 0, 128, 0, 64, 0, 160, 0, 64, 0, 192, 0, 64, 0, 224, 0, 64, 32, 0, 0, 64, 32, 32, 0, 64, 32, 64, 0, 64, 32, 96, 0, 64, 32, 128, 0, 64, 32, 160, 0, 64, 32, 192, 0, 64, 32, 224, 0, 64, 64, 0, 0, 64, 64, 32, 0, 64, 64, 64, 0, 64, 64, 96, 0, 64, 64, 128, 0, 64, 64, 160, 0, 64, 64, 192, 0, 64, 64, 224, 0, 64, 96, 0, 0, 64, 96, 32, 0, 64, 96, 64, 0, 64, 96, 96, 0, 64, 96, 128, 0, 64, 96, 160, 0, 64, 96, 192, 0, 64, 96, 224, 0, 64, 128, 0, 0, 64, 128, 32, 0, 64, 128, 64, 0, 64, 128, 96, 0, 64, 128, 128, 0, 64, 128, 160, 0, 64, 128, 192, 0, 64, 128, 224, 0, 64, 160, 0, 0, 64, 160, 32, 0, 64, 160, 64, 0, 64, 160, 96, 0, 64, 160, 128, 0, 64, 160, 160, 0, 64, 160, 192, 0, 64, 160, 224, 0, 64, 192, 0, 0, 64, 192, 32, 0, 64, 192, 64, 0, 64, 192, 96, 0, 64, 192, 128, 0, 64, 192, 160, 0, 64, 192, 192, 0, 64, 192, 224, 0, 64, 224, 0, 0, 64, 224, 32, 0, 64, 224, 64, 0, 64, 224, 96, 0, 64, 224, 128, 0, 64, 224, 160, 0, 64, 224, 192, 0, 64, 224, 224, 0, 128, 0, 0, 0, 128, 0, 32, 0, 128, 0, 64, 0, 128, 0, 96, 0, 128, 0, 128, 0, 128, 0, 160, 0, 128, 0, 192, 0, 128, 0, 224, 0, 128, 32, 0, 0, 128, 32, 32, 0, 128, 32, 64, 0, 128, 32, 96, 0, 128, 32, 128, 0, 128, 32, 160, 0, 128, 32, 192, 0, 128, 32, 224, 0, 128, 64, 0, 0, 128, 64, 32, 0, 128, 64, 64, 0, 128, 64, 96, 0, 128, 64, 128, 0, 128, 64, 160, 0, 128, 64, 192, 0, 128, 64, 224, 0, 128, 96, 0, 0, 128, 96, 32, 0, 128, 96, 64, 0, 128, 96, 96, 0, 128, 96, 128, 0, 128, 96, 160, 0, 128, 96, 192, 0, 128, 96, 224, 0, 128, 128, 0, 0, 128, 128, 32, 0, 128, 128, 64, 0, 128, 128, 96, 0, 128, 128, 128, 0, 128, 128, 160, 0, 128, 128, 192, 0, 128, 128, 224, 0, 128, 160, 0, 0, 128, 160, 32, 0, 128, 160, 64, 0, 128, 160, 96, 0, 128, 160, 128, 0, 128, 160, 160, 0, 128, 160, 192, 0, 128, 160, 224, 0, 128, 192, 0, 0, 128, 192, 32, 0, 128, 192, 64, 0, 128, 192, 96, 0, 128, 192, 128, 0, 128, 192, 160, 0, 128, 192, 192, 0, 128, 192, 224, 0, 128, 224, 0, 0, 128, 224, 32, 0, 128, 224, 64, 0, 128, 224, 96, 0, 128, 224, 128, 0, 128, 224, 160, 0, 128, 224, 192, 0, 128, 224, 224, 0, 192, 0, 0, 0, 192, 0, 32, 0, 192, 0, 64, 0, 192, 0, 96, 0, 192, 0, 128, 0, 192, 0, 160, 0, 192, 0, 192, 0, 192, 0, 224, 0, 192, 32, 0, 0, 192, 32, 32, 0, 192, 32, 64, 0, 192, 32, 96, 0, 192, 32, 128, 0, 192, 32, 160, 0, 192, 32, 192, 0, 192, 32, 224, 0, 192, 64, 0, 0, 192, 64, 32, 0, 192, 64, 64, 0, 192, 64, 96, 0, 192, 64, 128, 0, 192, 64, 160, 0, 192, 64, 192, 0, 192, 64, 224, 0, 192, 96, 0, 0, 192, 96, 32, 0, 192, 96, 64, 0, 192, 96, 96, 0, 192, 96, 128, 0, 192, 96, 160, 0, 192, 96, 192, 0, 192, 96, 224, 0, 192, 128, 0, 0, 192, 128, 32, 0, 192, 128, 64, 0, 192, 128, 96, 0, 192, 128, 128, 0, 192, 128, 160, 0, 192, 128, 192, 0, 192, 128, 224, 0, 192, 160, 0, 0, 192, 160, 32, 0, 192, 160, 64, 0, 192, 160, 96, 0, 192, 160, 128, 0, 192, 160, 160, 0, 192, 160, 192, 0, 192, 160, 224, 0, 192, 192, 0, 0, 192, 192, 32, 0, 192, 192, 64, 0, 192, 192, 96, 0, 192, 192, 128, 0, 192, 192, 160, 0, 240, 251, 255, 0, 164, 160, 160, 0, 128, 128, 128, 0, 0, 0, 255, 0, 0, 255, 0, 0, 0, 255, 255, 0, 255, 0, 0, 0, 255, 0, 255, 0, 255, 255, 0, 0, 255, 255, 255, 0}; RGBQUAD rgbquad16[16] = { 0, 0, 0, 0,//黑 128, 0, 0, 0, 0, 128, 0, 0, 128, 128, 0, 0, 0, 0, 128, 0, 128, 0, 128, 0, 0, 128, 128, 0, 128, 128, 128, 0, 192, 192, 192, 0, 255, 0, 0, 0, 0, 255, 0, 0, 255, 255, 0, 0, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 255, 0, 255, 255, 255, 0//白 }; RGBQUAD rgbquadGray[16];//用函数初始化 int getIndex(BYTE R, BYTE G, BYTE B, RGBQUAD *rgbquad, int size) {//获得rgb在调色板中最接近颜色的索引 int min_dist = 1000; int dist; int i; int min_index = 0; for (i = 0; i < size; i++) { dist = abs(rgbquad[i].rgbRed - R) + abs(rgbquad[i].rgbGreen - G) + abs(rgbquad[i].rgbBlue - B); if (dist < min_dist) { min_dist = dist; min_index = i; } } return min_index; } int getGrayIndex(BYTE R, BYTE G, BYTE B, RGBQUAD *rgbquad, int size) {//获得rgb在灰度调色板中最接近颜色的索引 double gray = 0.299 * R + 0.587 * G + 0.114 * B; int index; index = int(gray / 17); return index; } void initGray() { int i; for (i = 0; i < 16; i++) { rgbquadGray[i].rgbRed = i * 17; rgbquadGray[i].rgbGreen = i * 17; rgbquadGray[i].rgbBlue = i * 17; rgbquadGray[i].rgbReserved = 0; } } //16色转24bits真彩色 void convert4bitsTo24bits(FILE* fp, FILE* fres){ rewind(fp); RGBQUAD rgb[256]; BITMAPFILEHEADER bf, bfr; BITMAPINFOHEADER bi, bir; int colors; int i, j, k; int colorIndex, colorIndex2; int Width, Height; BYTE pixel[4]; fread(&bf, sizeof(bf), 1, fp); fread(&bi, sizeof(bi), 1, fp); colors = 1 << bi.biBitCount; fread(rgb, sizeof(RGBQUAD), colors, fp); Height = bi.biHeight; Width = bi.biWidth; bfr = bf; bir = bi; bir.biBitCount = 24; bfr.bfOffBits = 54; bfr.bfSize = Height * ((Width * 24 + 31) / 32 * 4) + 54;//4字节对齐后的size fwrite(&bfr, sizeof(bfr), 1, fres); fwrite(&bir, sizeof(bir), 1, fres); for (j = 0; j < Height; j++) { k = 0; for (i = 0; i < Width; i = i + 2) { fread(&colorIndex, 1, 1, fp); colorIndex2 = colorIndex & 0xf0 >> 4; colorIndex = colorIndex & 0xf; pixel[0] = rgb[colorIndex].rgbBlue; pixel[1] = rgb[colorIndex].rgbGreen; pixel[2] = rgb[colorIndex].rgbRed; fwrite(pixel, 3, 1, fres); pixel[0] = rgb[colorIndex2].rgbBlue; pixel[1] = rgb[colorIndex2].rgbGreen; pixel[2] = rgb[colorIndex2].rgbRed; fwrite(pixel, 3, 1, fres); } while ((i / 2) % 4 != 0) {//注意4字节对齐 fread(&colorIndex, 1, 1, fp); i = i + 2; } while ((Width * 3 % 4) + k != 0) {//4字节对齐 pixel[0] = 0; fwrite(pixel, 1, 1, fres); k++; } } } //256色转24bits真彩色 void convert8bitsTo24bits(FILE *fp, FILE *fres) { rewind(fp); RGBQUAD rgb[256]; BITMAPFILEHEADER bf, bfr; BITMAPINFOHEADER bi, bir; int colors; int i, j, k; int colorIndex, colorIndex2; int Width, Height; BYTE pixel[4]; fread(&bf, sizeof(bf), 1, fp); fread(&bi, sizeof(bi), 1, fp); colors = 1 << bi.biBitCount; fread(rgb, sizeof(RGBQUAD), colors, fp); Height = bi.biHeight; Width = bi.biWidth; bfr = bf; bir = bi; bir.biBitCount = 24; bfr.bfOffBits = 54; bfr.bfSize = Height * ((Width * 24 + 31) / 32 * 4) + 54;//4字节对齐后的size fwrite(&bfr, sizeof(bfr), 1, fres); fwrite(&bir, sizeof(bir), 1, fres); if (colors == 256) {//将256色转化成24bits真彩色 for (j = 0; j < Height; j++) { k = 0; for (i = 0; i < Width; i++) { fread(&colorIndex, 1, 1, fp); pixel[0] = rgb[colorIndex].rgbBlue; pixel[1] = rgb[colorIndex].rgbGreen; pixel[2] = rgb[colorIndex].rgbRed; fwrite(pixel, 3, 1, fres); } while ((Width * 3 % 4) + k != 0) {//4字节对齐 pixel[0] = 0; fwrite(pixel, 1, 1, fres); k++; } } } } //24bits真彩色转16色 void convert24bitsTo4bits(FILE* fp, FILE* fres){ BITMAPFILEHEADER bf, bfr; BITMAPINFOHEADER bi, bir; int i, j; int Height, Width; BYTE pixel[4]; int index, index2; fread(&bf, sizeof(bf), 1, fp); fread(&bi, sizeof(bi), 1, fp); bfr = bf; bir = bi; bfr.bfSize = 54 + 16 * 4 + Height * ((Width * 4 + 31) / 32 * 4); bfr.bfOffBits = 54 + 64; bir.biBitCount = 4; Height = bi.biHeight; Width = bi.biWidth; fwrite(&bfr, sizeof(bfr), 1, fres); fwrite(&bir, sizeof(bir), 1, fres); fwrite(&rgbquad16, sizeof(RGBQUAD), 16, fres);//写入调色板 for (j = 0; j < Height; j++) { for (i = 0; i < Width; i = i + 2) { fread(&pixel, 3, 1, fp); index = getIndex(pixel[2], pixel[1], pixel[0], rgbquad16, 16); fread(&pixel, 3, 1, fp); index2 = getIndex(pixel[2], pixel[1], pixel[0], rgbquad16, 16); index = (index << 4) | index2; //cout << index2 << endl; fwrite(&index, 1, 1, fres); } while ((i / 2) % 4 != 0) {//4字节对齐 index = 0; fwrite(&index, 1, 1, fres); i = i + 2; } } cout << "Convert to 4bits bmp success." << endl; } //24bits真彩色转256色 void convert24bitsTo8bits(FILE* fp, FILE* fres){ BITMAPFILEHEADER bf, bfr; BITMAPINFOHEADER bi, bir; int i, j; int Height, Width; BYTE pixel[4]; int index; fread(&bf, sizeof(bf), 1, fp); fread(&bi, sizeof(bi), 1, fp); bfr = bf; bir = bi; bfr.bfSize = 54 + 256 * 4 + Height * ((Width * 8 + 31) / 32 * 4); bfr.bfOffBits = 54 + 1024; bir.biBitCount = 8; Height = bi.biHeight; Width = bi.biWidth; fwrite(&bfr, sizeof(bfr), 1, fres); fwrite(&bir, sizeof(bir), 1, fres); fwrite(&rgbquad, sizeof(rgbquad), 1, fres);//写入调色板 for (j = 0; j < Height; j++) { for (i = 0; i < Width; i++) { if (fread(&pixel, 3, 1, fp)) { index = getIndex(pixel[2], pixel[1], pixel[0], rgbquad, 256); } else { //cout << ftell(fp) << endl; break; } fwrite(&index, 1, 1, fres); } } cout << "Convert to 8bits bmp success." << endl; } //24bits真彩色转灰度 void convert24bitsToGray(FILE* fp, FILE* fres){ BITMAPFILEHEADER bf, bfr; BITMAPINFOHEADER bi, bir; int i, j; int Height, Width; BYTE pixel[4]; int index, index2; initGray(); fread(&bf, sizeof(bf), 1, fp); fread(&bi, sizeof(bi), 1, fp); bfr = bf; bir = bi; bfr.bfSize = 54 + 16 * 4 + Height * ((Width * 4 + 31) / 32 * 4); bfr.bfOffBits = 54 + 64; bir.biBitCount = 4; Height = bi.biHeight; Width = bi.biWidth; fwrite(&bfr, sizeof(bfr), 1, fres); fwrite(&bir, sizeof(bir), 1, fres); fwrite(&rgbquadGray, sizeof(rgbquadGray), 1, fres);//写入调色板 for (j = 0; j < Height; j++) { for (i = 0; i < Width; i = i + 2) { fread(&pixel, 3, 1, fp); index = getGrayIndex(pixel[2], pixel[1], pixel[0], rgbquad16, 16); fread(&pixel, 3, 1, fp); index2 = getGrayIndex(pixel[2], pixel[1], pixel[0], rgbquad16, 16); index = (index << 4) | index2; fwrite(&index, 1, 1, fres); } while ((i / 2) % 4 != 0) {//4字节对齐 index = 0; fwrite(&index, 1, 1, fres); i = i + 2; } } cout << "Convert to gray bmp success." << endl; } //16阶灰度图像转抖动黑白图像 void convertGrayToBlackWhite(FILE *fp, FILE *fres) { BITMAPFILEHEADER bf, bfr; BITMAPINFOHEADER bi, bir; int i, j; int Height, Width; BYTE pixel[4]; int M[4][4] = {{0, 8, 2, 10}, {12, 4, 14, 6}, {3, 11, 1, 9}, {15, 7, 13, 5}};//抖动矩阵 initGray(); fread(&bf, sizeof(bf), 1, fp); fread(&bi, sizeof(bi), 1, fp); bfr = bf; bir = bi; Height = bi.biHeight; Width = bi.biWidth; bfr.bfSize = 54 + 16 * 4 + Height * 4 * ((Width * 4 * 4 + 31) / 32 * 4); bfr.bfOffBits = 54 + 64; bir.biHeight = 4 * Height; bir.biWidth = 4 * Width; bir.biBitCount = 4; fwrite(&bfr, sizeof(bfr), 1, fres); fwrite(&bir, sizeof(bir), 1, fres); fwrite(&rgbquadGray, sizeof(rgbquadGray), 1, fres);//写入调色板 BYTE BlackWhite[2000][2000];//储存黑白图像 BYTE pixel0, pixel1; int k, l; fseek(fp, bf.bfOffBits, 0);//因为没有读灰度图像的调色板,所以把指针移动到图像信息开始位置,这里有点坑 for (j = 0; j < Height; j++) { for (i = 0; i < Width; i = i + 2) { fread(&pixel, 1, 1, fp); pixel0 = pixel[0] & 0xf0 >> 4; pixel1 = pixel[0] & 0x0f; for (l = 0; l < 4; l++) { for (k = 0; k < 4; k++) { if (pixel0 >= M[k][l]) { BlackWhite[j * 4 + k][i * 4 + l] = 0xf; } else { BlackWhite[j * 4 + k][i * 4 + l] = 0; } } } for (l = 0; l < 4; l++) { for (k = 0; k < 4; k++) { if (pixel1 >= M[k][l]) { BlackWhite[j * 4 + k][(i + 1) * 4 + l] = 0xf; } else { BlackWhite[j * 4 + k][(i + 1) * 4 + l] = 0; } } } } while ((i / 2) % 4 != 0) {//注意读取时的4字节对齐!格外注意 fread(&pixel, 1, 1, fp); i = i + 2; } } //将黑白图写入BMP int index; for (j = 0; j < Height*4; j++) { for (i = 0; i < Width*4; i = i + 2) { index = (BlackWhite[j][i]<<4) | BlackWhite[j][i+1]; fwrite(&index, 1, 1, fres); } while ((i / 2) % 4 != 0) {//4字节对齐 index = 0; fwrite(&index, 1, 1, fres); i = i + 2; } } cout << "Convert to black white bmp success." << endl; } int main() { FILE *fp, *fres; BITMAPFILEHEADER bf; BITMAPINFOHEADER bi; char originalFile[100], resultFile[100]; cout<<"Please input the original filename"<<endl; cin>>originalFile; cout<<"Please input the result filename"<<endl; cin>>resultFile; if ((fp = fopen(originalFile, "rb")) == NULL) { cout << "Open file failed." << endl; } if ((fres = fopen("24bits.bmp", "wb")) == NULL) { cout << "Create file failed." << endl; } fread(&bf, sizeof(bf), 1, fp); fread(&bi, sizeof(bi), 1, fp); if (bi.biBitCount == 8) {//256色 convert8bitsTo24bits(fp, fres); printf("This is a 8 bits BMP picture.\n"); } else if (bi.biBitCount == 4) {//16色 convert4bitsTo24bits(fp, fres); printf("This is a 4 bits BMP picture.\n"); } else if (bi.biBitCount == 24) {//24位真彩色 printf("This is a 24 bits BMP picture.\n"); } //-------------------此条线以上部分将256色和16色输入图像统一转化为24bits真彩BMP,储存到result.bmp中 cout << "Please choose the target type" << endl; cout << "----to 8 bits BMP : 0" << endl; cout << "----to 4 bits BMP : 1" << endl; cout << "----to 24 bits BMP : 2" << endl; cout << "----to Gray BMP : 3" << endl; cout << "----to BlackWhite BMP : 4" << endl; int target; cin >> target; fclose(fp); fclose(fres); if ((fp = fopen("24bits.bmp", "rb")) == NULL) {//打开真彩文件 cout << "Open 24bits file failed." << endl; } if ((fres = fopen(resultFile, "wb")) == NULL) {//创建最终的目标文件 cout << "Create file failed." << endl; } switch (target) { case (to8bits): {//将24bits真彩色转换为256色 convert24bitsTo8bits(fp, fres); break; } case (to4bits): {//将24bits真彩色转换为16色 convert24bitsTo4bits(fp, fres); break; } case (to24bits): { cout << "Convert to 24bits bmp success." << endl; break; } case (toGray): {//将24bits真彩色转换为16色灰度图 convert24bitsToGray(fp, fres); break; } case (toBlackwhite): {//将24bits真彩图转化为抖动黑白图像 FILE* ftmp; ftmp = fopen("tmpGray.bmp", "wb+"); convert24bitsToGray(fp, ftmp);//先将真彩图转化为灰度图 rewind(ftmp); convertGrayToBlackWhite(ftmp, fres); fclose(ftmp); break; default: break; } } fclose(fp); fclose(fres); return 0; }
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- ** ** Copyright (C) 1995-2006 Opera Software ASA. All rights reserved. ** ** This file is part of the Opera web browser. It may not be distributed ** under any circumstances. ** */ #include "core/pch.h" #if defined(SVG_SUPPORT) && defined(SVG_DOM) && defined(SVG_FULL_11) #include "modules/svg/src/svgpch.h" #include "modules/svg/src/svgdom/svgdommatrixtransformimpl.h" SVGDOMMatrixTransformImpl::SVGDOMMatrixTransformImpl(SVGTransform* transform) : m_transform(transform) { SVGObject::IncRef(m_transform); } /* virtual */ SVGDOMMatrixTransformImpl::~SVGDOMMatrixTransformImpl() { SVGObject::DecRef(m_transform); } /* virtual */ OP_BOOLEAN SVGDOMMatrixTransformImpl::SetValue(int idx, double x) { SVGMatrix tmp; m_transform->GetMatrix(tmp); if (m_transform->GetTransformType() != SVGTRANSFORM_MATRIX) { m_transform->SetMatrix(tmp); } else { RETURN_FALSE_IF(tmp[idx] == SVGNumber(x)); } m_transform->values[idx] = SVGNumber(x); return OpBoolean::IS_TRUE; } /* virtual */ double SVGDOMMatrixTransformImpl::GetValue(int idx) { SVGMatrix tmp; m_transform->GetMatrix(tmp); return tmp[idx].GetFloatValue(); } /* virtual */ void SVGDOMMatrixTransformImpl::GetMatrix(SVGMatrix& matrix) const { m_transform->GetMatrix(matrix); } /* virtual */ void SVGDOMMatrixTransformImpl::SetMatrix(const SVGMatrix& matrix) { m_transform->SetMatrix(matrix); } #endif // SVG_DOM && SVG_SUPPORT && SVG_FULL_11
class Solution { public: int calculate(string s) { int sum = 0, num = 0; char op = '+'; stack<int> stk; for(int i = 0; i < s.size(); ++i){ if(isdigit(s[i])){ num = num*10 + (s[i] - '0'); } if(!isdigit(s[i]) && s[i] != ' ' || i == s.size()-1){ if(op =='-'){ num =-num; }else if(op != '+'){ int prev = stk.top(); stk.pop(); if(op == '*') num *= prev; else num = prev/num; } stk.push(num); num = 0; op = s[i]; } } while(!stk.empty()){ sum += stk.top(); stk.pop(); } return sum; } }; class Solution { public: int calculate(string s) { istringstream in('+' + s + '+'); int num = 0, sum = 0, next; char op; while(in >> op){ if(op == '+' || op == '-'){ sum += num; in >> num; if(op == '-') num = -num; }else{ in >> next; if(op == '*') num *= next; else num /= next; } } return sum; } }; class Solution { public: int calculate(string s) { stack<int> nums; stack<char> ops; istringstream in(s); int num; char op; bool flag = false; while(flag || in >> num){ nums.push(num); flag = false; in >> op; if(in.eof()) break; if(op == '+' || op == '-'){ ops.push(op); }else{ flag = true; int prev = nums.top(); nums.pop(); int next; in >> next; if(op == '*'){ num = prev*next; }else{ num = prev/next; } } } int res = 0; while(!nums.empty()){ int num = nums.top(); nums.pop(); if(nums.empty()){ res += num; break; } op = ops.top(); ops.pop(); if(op == '-') res -= num; else res += num; } return res; } };
#ifdef DEBUG #define _GLIBCXX_DEBUG #endif #include <iostream> #include <algorithm> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <memory.h> #include <math.h> #include <string> #include <string.h> #include <queue> #include <vector> #include <set> #include <deque> #include <map> #include <functional> #include <numeric> #include <sstream> typedef long double LD; typedef long long LL; typedef unsigned long long ULL; typedef unsigned int uint; #define PI 3.1415926535897932384626433832795 #define sqr(x) ((x)*(x)) using namespace std; LL k, n; int sn = 0; int s[111], ss[111], ssn = 0; LL mem1[222][22]; LL mem2[222][22]; LL Calc(int su, int l) { if (l == 0) return su == 0; if (su < 0) return 0; if (l < 0) return 0; LL& ans = mem1[su][l]; if (ans != -1) return ans; ans = 0; for (int i = 0; i <= 9; ++i) { ans += Calc(su - i, l - 1); } return ans; } LL Calc(int su, int* s, int sn, bool first) { if (su < 0) return 0; if (sn == 0) return su == 0; LL& ans = mem2[su][sn]; if (ans != -1) return ans; ans = 0; for (int i = first; i <= 9; ++i) { if (i < s[sn - 1]) ans += Calc(su - i, sn - 1);else if (i == s[sn - 1]) ans += Calc(su - i, s, sn - 1, false); } return ans; } int main() { freopen("grlex.in", "r", stdin); freopen("grlex.out", "w", stdout); memset(mem1, -1, sizeof(mem1)); memset(mem2, -1, sizeof(mem2)); cin >> n >> k; LL K = k; while (n) { s[sn++] = n % 10; n /= 10; } for (int su = 1; su <= 180; ++su) { LL c = Calc(su, s, sn, false); if (c >= k) { bool eq = true; int it = 0; int ssu = su; while (k) { if (ssu == 0 && k == 1) break; if (ssu == 0) --k; for (int i = (it == 0); i <= 9; ++i) { LL cc = 0; for (int j = 0; j <= sn; ++j) { if (eq) { if (i < s[sn - it - 1]) { cc += Calc(ssu - i, j - it - 1); } else if (i > s[sn - it - 1]) { cc += Calc(ssu - i, j - it - 2); } else { cc += Calc(ssu - i, s, sn - 1, false); } } else { cc += Calc(ssu - i, j - it - 1); } } if (cc >= k) { cout << i; eq &= s[sn - 1 - it] == i; ssu -= i; break; } k -= cc; } ++it; } break; } k -= c; } LL ans = 0; int kk = K, su = 0; while (kk > 0) { ss[ssn++] = kk % 10; su += kk % 10; kk /= 10; } for (int i = 1; i < su; ++i) ans += Calc(i, s, sn, false); ans += Calc(su, ssn - 1); for (int i = 0; i < ssn; ++i) { for (int d = 0; d < ss[ssn - i - 1]; ++d) { ans += Calc(su - d, ssn - i - 1); } su -= ss[ssn - i - 1]; } cout << " " << ans << endl; return 0; }
// Mon Jan 11 16:53:20 EST 2016 // Evan S Weinberg // Header file for templated vector operations. #include <complex> #include <random> #ifndef GENERIC_VECTOR #define GENERIC_VECTOR // Zeroes a vector. template<typename T> inline void zero(T* v1, int size) { int i; for (i = 0; i < size; i++) { v1[i] = 0.0; } } // Zeroes a complex vector. template <typename T> inline void zero(std::complex<T>* v1, int size) { // Initialize. int i; for (i = 0; i < size; i++) { v1[i] = 0.0; } } // Random gaussian vector. template<typename T> inline void gaussian(T* v1, int size, std::mt19937 &generator) { // Generate a normal distribution. std::normal_distribution<> dist(0.0, 1.0); int i; for (i = 0; i < size; i++) { v1[i] = static_cast<T>(dist(generator)); } } // Random gaussian vector, random in real and imag. template <typename T> inline void gaussian(std::complex<T>* v1, int size, std::mt19937 &generator) { // Generate a normal distribution. std::normal_distribution<> dist(0.0, 1.0); // Initialize. int i; for (i = 0; i < size; i++) { v1[i] = std::complex<T>(static_cast<T>(dist(generator)), static_cast<T>(dist(generator))); } } // Copy v2 into v1. template<typename T> inline void copy(T* v1, T* v2, int size) { // Initialize. int i; for (i = 0; i < size; i++) { v1[i] = v2[i]; } } // Copy v2 into v1. template<typename T> inline void copy(std::complex<T>* v1, std::complex<T>* v2, int size) { // Initialize. int i; for (i = 0; i < size; i++) { v1[i] = v2[i]; } } // Computes v1 dot v2. template<typename T> inline T dot(T* v1, T* v2, int size) { // Initialize. int i; T res = (T)0.0; for (i = 0; i < size; i++) { res = res + v1[i]*v2[i]; } return res; } // computes conj(v1) dot v2. template <typename T> inline std::complex<T> dot(std::complex<T>* v1, std::complex<T>* v2, int size) { // Initialize. int i; std::complex<T> res = (T)0.0; for (i = 0; i < size; i++) { res = res + conj(v1[i])*v2[i]; } return res; } template <typename T> inline T norm2sq(T* v1, int size) { // Initialize. int i; T res = (T)0.0; for (i = 0; i < size; i++) { res = res + v1[i]*v1[i]; } return res; } template <typename T> inline T norm2sq(std::complex<T>* v1, int size) { // Initialize. int i; T res = (T)0.0; for (i = 0; i < size; i++) { res = res + real(conj(v1[i])*v1[i]); } return res; } // Return |v1 - v2| template <typename T> inline T diffnorm2sq(T* v1, T* v2, int size) { int i; T res = (T)0.0; for (i = 0; i < size; i++) { res = res + (v1[i] - v2[i])*(v1[i] - v2[i]); } return res; } template <typename T> inline T diffnorm2sq(std::complex<T>* v1, std::complex<T>* v2, int size) { int i; T res = (T)0.0; for (i = 0; i < size; i++) { res = res + real(conj(v1[i] - v2[i])*(v1[i] - v2[i])); } return res; } template <typename T> inline void normalize(T* v1, int size) { int i; T res = static_cast<T>(0.0); res = 1.0/sqrt(norm2sq<T>(v1, size)); if (res > 0.0) { for (i = 0; i < size; i++) { v1[i] *= res; } } } template <typename T> inline void normalize(std::complex<T>* v1, int size) { int i; T res = static_cast<T>(0.0); res = 1.0/sqrt(norm2sq<T>(v1, size)); if (res > 0.0) { for (i = 0; i < size; i++) { v1[i] *= res; } } } template <typename T> inline void conj(T* v1, int size) { return; // Trivial, it's real. } template <typename T> inline void conj(std::complex<T>* v1, int size) { int i; for (i = 0; i < size; i++) { v1[i] = conj(v1[i]); } } // Make vector v1 orthogonal to vector v2. template <typename T> inline void orthogonal(T* v1, T* v2, int size) { int i; T alpha; alpha = -dot<T>(v2, v1, size)/norm2sq<T>(v2, size); for (i = 0; i < size; i++) { v1[i] = v1[i] + alpha*v2[i]; } } // Make vector v1 orthogonal to vector v2. template <typename T> inline void orthogonal(std::complex<T>* v1, std::complex<T>* v2, int size) { int i; std::complex<T> alpha; alpha = -dot<T>(v2, v1, size)/norm2sq<T>(v2, size); for (i = 0; i < size; i++) { v1[i] = v1[i] + alpha*v2[i]; } } #endif // GENERIC_VECTOR
/* * Copyright 2016 Freeman Zhang <zhanggyb@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <skland/wayland/xdg-toplevel.hpp> #include <skland/wayland/seat.hpp> #include <skland/wayland/output.hpp> #include "internal/xdg-toplevel-meta.hpp" #include "internal/xdg-surface-meta.hpp" namespace skland { namespace wayland { XdgToplevel::XdgToplevel() { metadata_.reset(new XdgToplevelMeta); } XdgToplevel::~XdgToplevel() { } void XdgToplevel::Setup(const XdgSurface &xdg_surface) { Destroy(); metadata_->zxdg_toplevel = zxdg_surface_v6_get_toplevel(xdg_surface.metadata_->zxdg_surface); zxdg_toplevel_v6_add_listener(metadata_->zxdg_toplevel, &XdgToplevelMeta::kListener, this); } void XdgToplevel::Destroy() { if (metadata_->zxdg_toplevel) { zxdg_toplevel_v6_destroy(metadata_->zxdg_toplevel); metadata_->zxdg_toplevel = nullptr; } } void XdgToplevel::SetParent(const XdgToplevel &parent) const { zxdg_toplevel_v6_set_parent(metadata_->zxdg_toplevel, parent.metadata_->zxdg_toplevel); } void XdgToplevel::SetTitle(const char *title) const { zxdg_toplevel_v6_set_title(metadata_->zxdg_toplevel, title); } void XdgToplevel::SetAppId(const char *app_id) const { zxdg_toplevel_v6_set_app_id(metadata_->zxdg_toplevel, app_id); } void XdgToplevel::ShowWindowMenu(const Seat &seat, uint32_t serial, int32_t x, int32_t y) const { zxdg_toplevel_v6_show_window_menu(metadata_->zxdg_toplevel, seat.wl_seat_, serial, x, y); } void XdgToplevel::Move(const Seat &seat, uint32_t serial) const { zxdg_toplevel_v6_move(metadata_->zxdg_toplevel, seat.wl_seat_, serial); } void XdgToplevel::Resize(const Seat &seat, uint32_t serial, uint32_t edges) const { zxdg_toplevel_v6_resize(metadata_->zxdg_toplevel, seat.wl_seat_, serial, edges); } void XdgToplevel::SetMaxSize(int32_t width, int32_t height) const { zxdg_toplevel_v6_set_max_size(metadata_->zxdg_toplevel, width, height); } void XdgToplevel::SetMinSize(int width, int height) const { zxdg_toplevel_v6_set_min_size(metadata_->zxdg_toplevel, width, height); } void XdgToplevel::SetMaximized() const { zxdg_toplevel_v6_set_maximized(metadata_->zxdg_toplevel); } void XdgToplevel::UnsetMaximized() const { zxdg_toplevel_v6_unset_maximized(metadata_->zxdg_toplevel); } void XdgToplevel::SetFullscreen(const Output &output) const { zxdg_toplevel_v6_set_fullscreen(metadata_->zxdg_toplevel, output.wl_output_); } void XdgToplevel::UnsetFullscreen(const Output &output) const { zxdg_toplevel_v6_unset_fullscreen(metadata_->zxdg_toplevel); } void XdgToplevel::SetMinimized() const { zxdg_toplevel_v6_set_minimized(metadata_->zxdg_toplevel); } void XdgToplevel::SetUserData(void *user_data) const { zxdg_toplevel_v6_set_user_data(metadata_->zxdg_toplevel, user_data); } void *XdgToplevel::GetUserData() const { return zxdg_toplevel_v6_get_user_data(metadata_->zxdg_toplevel); } uint32_t XdgToplevel::GetVersion() const { return zxdg_toplevel_v6_get_version(metadata_->zxdg_toplevel); } bool XdgToplevel::IsValid() const { return nullptr != metadata_->zxdg_toplevel; } } }
#include <string> #include <windows.h> namespace CPP { class PrinterInfo { public: std::string getDefaultPrinterInfo() const { char szPrinterName[255]; unsigned long lPrinterNameLength; GetDefaultPrinter(szPrinterName, &lPrinterNameLength); return std::string(szPrinterName); } }; }
/* * Algorithm : Merge Sort * Time Complexity : O(n*log(n)) * Space Complexity : O(n) */ #include <bits/stdc++.h> using namespace std; void merge(int array[],int left,int mid,int right){ int subArrayLeft = mid-left+1; int subArrayRight = right-mid; int leftArray[subArrayLeft]; int rightArray[subArrayRight]; for(int i=0;i<subArrayLeft;i++){ leftArray[i] = array[left+i]; } for(int i=0;i<subArrayRight;i++){ rightArray[i] = array[mid+1+i]; } int i=0,j=0,k=left; while(i<subArrayLeft && j<subArrayRight){ if(leftArray[i]<=rightArray[j]){ array[k] = leftArray[i]; i++; }else{ array[k] = rightArray[j]; j++; } k++; } while(i<subArrayLeft){ array[k] = leftArray[i]; i++; k++; } while(j<subArrayRight){ array[k] = rightArray[j]; j++; k++; } } void mergeSort(int arr[],int l,int r){ // arr:{38,27,43,3,9,82,10} l : 0 r : 7 if(l>=r){ return; } int m = l + (r-l)/2; mergeSort(arr,l,m); mergeSort(arr,m+1,r); merge(arr,l,m,r); } int main(){ int arr[] = {38,27,43,3,9,82,10}; int n = sizeof(arr)/sizeof(arr[0]); mergeSort(arr,0,n-1); for(int i=0;i<n;i++){ cout << arr[i] << " "; } return 0; }
#include "mainwindow.h" #include <QApplication> QMovie *movie; int xyz[3][100]; Node* Head; Node* Now; int begin_tag=0; int number=0; int draw_tag=0; int rand_tag=0; QString str; int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
#include <stdio.h> #include <iostream> #include <math.h> #include <algorithm> #include <memory.h> #include <set> #include <map> #include <queue> #include <deque> #include <string> #include <string.h> #include <vector> typedef long long ll; typedef long double ld; typedef unsigned long long ull; const ld PI = acos(-1.); using namespace std; const int N = 200222; const int M = 19; char w[N]; int balance[N]; int suf[N], cnt[N], classes, p[N], mod[N + N + N]; int cls[M][N]; int lcp[N]; vector<int> g[N]; map<int, int> where; int kv; pair<int, int> st; int rmin[N]; int main() { freopen("abyss.in", "r", stdin); freopen("abyss.out", "w", stdout); gets(w); int l = strlen(w); if (w[0] == '0') balance[0] = 1; else balance[0] = -1; for (int i = 1; i < l; ++i) { int add = w[i] == '0' ? 1 : -1; balance[i] = balance[i - 1] + add; } kv = 0; for (int i = 0; i < l; ++i) { map<int, int>::iterator it = where.find(balance[i]); int pos; if (it == where.end()) { pos = where[ balance[i] ] = kv++; } else pos = it->second; g[pos].push_back(i); } l++; // add 0 to string for (int i = 0; i < l; ++i) { mod[i] = mod[i + l] = mod[i + l + l] = i; } classes = 256; for (int i = 0; i < l; ++i) { cnt[ w[i] ]++; cls[0][i] = w[i]; } for (int i = 1; i < classes; ++i) cnt[i] += cnt[i - 1]; for (int i = l - 1; i >= 0; --i) { suf[ --cnt[ w[i] ] ] = i; } int mm = 0; for (int h = 0; (1 << h) <= l; ++h) { mm = h + 1; int half = 1 << h; memset(cnt, 0, sizeof(cnt[0]) * (classes + 3)); for (int i = 0; i < l; ++i) { p[i] = mod[suf[i] + l - half]; cnt[ cls[h][i] ]++; } for (int i = 1; i <= classes; ++i) { cnt[i] += cnt[i - 1]; } for (int i = l - 1; i >= 0; --i) { suf[ --cnt[ cls[h][ p[i] ] ] ] = p[i]; } int classes = 1; cls[h + 1][ suf[0] ] = 0; for (int i = 1; i < l; ++i) { if (cls[h][ suf[i] ] != cls[h][ suf[i - 1] ] || cls[h][ mod[ suf[i] + (1 << h) ] ] != cls[h][ mod[ suf[i - 1] + (1 << h) ] ]) { ++classes; } cls[h + 1][ suf[i] ] = classes - 1; } } for (int i = 0; i + 1 < l; ++i) { int x = suf[i], y = suf[i + 1]; for (int j = mm; j >= 0; --j) { if (cls[j][x] == cls[j][y]) { lcp[i] += (1 << j); x = mod[x + (1 << j)]; y = mod[y + (1 << j)]; } } } /* for (int i = 0; i < l; ++i) { printf("%s %d\n", w + suf[i], lcp[i]); } */ sz = 1; st[0] = make_pair(l, balance[l - 1]); for (int i = l - 1; i >= 0; --i) { int cur = i == 0 ? 0 : balance[i - 1]; while (st[sz - 1].second >= balance[i]) } for (int i = 1; i < l; ++i) { int pos = suf[i]; int border = pos + lcp[ suf[pos] ]; } return 0; }
#include <bits/stdc++.h> using namespace std; int countOnes(bool arr[], int low, int high) { if (high >= low) { int mid = low + (high - low)/2; if ( (mid == high || arr[mid+1] == 0) && (arr[mid] == 1)) return mid+1; if (arr[mid] == 1) return countOnes(arr, (mid + 1), high); return countOnes(arr, low, (mid -1)); } return 0; } int main() { bool arr[] = {1, 1, 0, 0, 0, 0, 0}; int n = sizeof(arr)/sizeof(arr[0]); cout << "Count of 1's in given array is " << countOnes(arr, 0, n-1); return 0; }
#include <memory> #include "Hooks.h" #ifdef _WIN32 #include <Windows.h> extern "C" BOOL WINAPI _CRT_INIT(HMODULE moduleHandle, DWORD reason, LPVOID reserved); BOOL APIENTRY DllEntryPoint(HMODULE moduleHandle, DWORD reason, LPVOID reserved) { if (!_CRT_INIT(moduleHandle, reason, reserved)) return FALSE; if (reason == DLL_PROCESS_ATTACH) { hooks = std::make_unique<Hooks>(moduleHandle); hooks->setup(); } return TRUE; } #else void __attribute__((constructor)) DllEntryPoint() { hooks = std::make_unique<Hooks>(); hooks->setup(); } #endif
#include "gtest/gtest.h" #include "wali/wfa/WFA.hpp" #include "wali/ShortestPathSemiring.hpp" #include "wali/LongestSaturatingPathSemiring.hpp" #include "wali/domains/binrel/ProgramBddContext.hpp" #include "wali/domains/binrel/BinRel.hpp" #include "fixtures.hpp" #define NUM_ELEMENTS(array) (sizeof(array)/sizeof((array)[0])) using namespace wali::wfa; static const WFA fas[] = { LoopReject().wfa, LoopAccept().wfa, EvenAsEvenBs().wfa, EpsilonTransitionToAccepting().wfa, EpsilonFull().wfa, EpsilonTransitionToMiddleToAccepting().wfa, ADeterministic().wfa, EpsilonTransitionToMiddleToEpsilonToAccepting().wfa, AcceptAbOrAcNondet().wfa, AEpsilonEpsilonEpsilonA().wfa }; Words ws; static const WFA::Word words[] = { ws.epsilon, ws.a, ws.b, ws.c, ws.aa, ws.ab, ws.ac }; static const unsigned num_fas = NUM_ELEMENTS(fas); static const unsigned num_words = NUM_ELEMENTS(words); static const bool answers[num_fas][num_words] = { // eps a b c aa ab ac { /* loop reject */ false, false, false, false, false, false, false }, { /* loop accept */ true, true, true, true, true, true, true }, { /* even As, even Bs */ true, false, false, false, true, false, false }, { /* eps -> accept */ true, false, false, false, false, false, false }, { /* epsilon deterministic */ true, false, false, false, false, false, false }, { /* eps -> mid -> acc */ false, true, false, false, false, false, false }, { /* A deterministic */ false, true, false, false, false, false, false }, { /* eps -> mid -> eps -> acc */ false, true, false, false, false, false, false }, { /* AB or AC nondet */ false, false, false, false, false, true, true }, { /* A eps eps eps A */ false, false, false, false, true, false, false } }; namespace wali { namespace wfa { TEST(wali$wfa$$isAcceptedWithNonzeroWeight, testBatteryOfVariousFas) { for (unsigned fa = 0 ; fa < num_fas ; ++fa) { for (unsigned word = 0 ; word < num_words ; ++word) { bool expected = answers[fa][word]; bool actual = fas[fa].isAcceptedWithNonzeroWeight(words[word]); std::stringstream ss; ss << "Testing FA #" << fa << " with string #" << word; SCOPED_TRACE(ss.str()); EXPECT_EQ(expected, actual); } } } } }
/* pins */ const uint8_t vref_pin = A1; const uint8_t az_pin = 2; const uint8_t x45out_pin = A2; const uint8_t z45out_pin = A3; /* values in mv */ double vref_mv; double x_mv; double z_mv; double x_val = 0; double z_val = 0; double x_cal = 0; double z_cal = 0; uint8_t az_cnt = 0; void TC8_Handler (void) { uint32_t status; status = TC2->TC_CHANNEL[2].TC_SR; vref_mv = analogRead(vref_pin) * 5000.0/1024.0; x_mv = analogRead(x45out_pin) * 5000.0/1024.0; z_mv = analogRead(z45out_pin) * 5000.0/1024.0; } void setup() { uint32_t cmr8_val = 0; pmc_set_writeprotect(false); pmc_enable_periph_clk(ID_TC8); /* configure TC8 */ cmr8_val |= TC_CMR_WAVE; /* waveform mode */ cmr8_val |= TC_CMR_WAVSEL_UP_RC; /* counting up until eq RC */ cmr8_val |= TC_CMR_TCCLKS_TIMER_CLOCK3; /* MCK/32 */ TC2->TC_CHANNEL[2].TC_RC = 262500; /* set RC val */ TC_Configure(TC2, 2, cmr8_val); TC2->TC_CHANNEL[2].TC_IER = TC_IER_CPCS; /* enable rc cmp interrupt */ TC2->TC_CHANNEL[2].TC_IDR = ~TC_IER_CPCS; /* not disable rc cmp interrupt */ /* enable interrupts */ NVIC_ClearPendingIRQ(TC8_IRQn); NVIC_EnableIRQ(TC8_IRQn); /* start timer */ TC_Start(TC2, 2); /* configure i/o pins */ pinMode(vref_pin, INPUT); pinMode(az_pin, OUTPUT); pinMode(x45out_pin, OUTPUT); pinMode(z45out_pin, OUTPUT); digitalWrite(az_pin, LOW); delay(6); vref_mv = analogRead(vref_pin) * 5000.0/1024.0; x_mv = analogRead(x45out_pin) * 5000.0/1024.0; z_mv = analogRead(z45out_pin) * 5000.0/1024.0; x_cal = (x_mv - vref_mv) / 9.1; z_cal = (z_mv - vref_mv) / 9.1; Serial.begin(9600); Serial.println("setup done"); } void loop() { delay(200); // if (az_cnt < 10) // { // ++az_cnt; // } // else // { // digitalWrite(az_pin, HIGH); // delay(1); // digitalWrite(az_pin, LOW); // delay(7); // az_cnt = 0; // } x_val = (x_mv - vref_mv) / 9.1 - x_cal; z_val = (z_mv - vref_mv) / 9.1 - z_cal; Serial.print("vref: "); Serial.print(vref_mv); Serial.print(' '); Serial.print(x_mv); Serial.print(' '); Serial.print(z_mv); Serial.print(" x: "); Serial.print(x_val); Serial.print(" z: "); Serial.print(z_val); Serial.print('\n'); }
//先根据输入数据,初始化存大小的数组map //再使用Floyd法,找出各个能确定的大小情况 //再循环对每头牛,找比他大和比他小的珍珠的个数 //如果以上两个个数,和为n-1,则可该牛名次可确定, //答案+1,最后输出个数 #include<cstdio> using namespace std; bool map[105][105];//存大小情况,如map[i][j]代表i比j大 int ans=0; int main() { int n,m; scanf("%d%d",&n,&m); for(int i=1;i<=m;i++) { int x,y; scanf("%d%d",&x,&y);//输入各数据 map[x][y]=1;//初始化map } for(int k=1;k<=n;k++) for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) { if(map[i][k] && map[k][j])//若i比k大并且k比j大 map[i][j]=1;//证明i大于j if(map[k][i] && map[j][k])//若i比k小并且j比k小 map[j][i]=1;//证明j大于i } for(int i=1;i<=n;i++)//循环找每个珍珠 { int sum1=0,sum2=0;//分别存比他小和比他大的珍珠数 for(int j=1;j<=n;j++) { if(map[j][i])//如果i比j大,则sum1++; sum1++; if(map[i][j])//若i比j小,则sum2++; sum2++; } if( sum1+sum2==n-1 )//若sum1与sum2和为n-1,则可确定 ans++;//ans++; } printf("%d",ans); }
#include "monitor.h" Monitor::Monitor(QObject *parent) : QObject(parent) { }
#include <Projection.h> void Projection::refresh() { this->projection = glm::perspective(this->fieldOfView, this->aspectRatio, this->near, this->far); } Projection::Projection() { this->fieldOfView = 45.0f; this->aspectRatio = 1440.0f / 900.0f; this->near = 1.0f; this->far = 1000.0f; this->refresh(); } Projection::Projection(float fieldOfView, float aspectRatio, float near, float far) { this->fieldOfView = fieldOfView; this->aspectRatio = aspectRatio; this->near = near; this->far = far; this->refresh(); } Projection::~Projection() { } mat4 Projection::getMatrix() { return this->projection; } mat4 * Projection::getProjection(){ return &this->projection; } float Projection::getFieldOfView() { return this->fieldOfView; } float Projection::getAspectRatio() { return this->aspectRatio; } float Projection::getNear() { return this->near; } float Projection::getFar() { return this->far; } void Projection::setFieldOfView(float fieldOfView) { this->fieldOfView = fieldOfView; this->refresh(); } void Projection::setAspectRatio(float aspectRatio) { this->aspectRatio = aspectRatio; this->refresh(); } void Projection::setNearAndFar(float near, float far) { this->near = near; this->far = far; this->refresh(); } void Projection::setNear(float near) { this->near = near; this->refresh(); } void Projection::setFar(float far) { this->far = far; this->refresh(); } void Projection::addFieldOfView(float fieldOfView) { this->fieldOfView += fieldOfView; this->refresh(); } void Projection::addAspectRatio(float aspectRatio) { this->aspectRatio += aspectRatio; this->refresh(); } void Projection::addNearAndFar(float near, float far) { this->near += near; this->far += far; this->refresh(); } void Projection::addNear(float near) { this->near = near; this->refresh(); } void Projection::addFar(float far) { this->far = far; this->refresh(); } void Projection::bind(CGLSLProgram * shader){ glUniformMatrix4fv(glGetUniformLocation(shader->getProgramID(), "u_projection_matrix"), 1, GL_FALSE, &(this->getMatrix())[0][0]); }
#pragma once #include "Module/Application.h" namespace Rocket { class SimpleApp : implements Application { public: RUNTIME_MODULE_TYPE(SimpleApp); SimpleApp() = default; virtual ~SimpleApp() = default; void PreInitializeModule() final; void PostInitializeModule() final; void PreInitialize() final; void PostInitialize() final; }; }
#include <stdio.h> #include <math.h> int main() { int a, b, c; double delta, raiz, x1, x2; printf("Equacao de segundo grau: "); printf("\nDigite o valor de a: "); scanf("%d", &a); printf("\nDigite o valor de b: "); scanf("%d", &b); printf("\nDigite o valor de c: "); scanf("%d", &c); if (a == 0) { printf("\nNao e uma equacao de segundo grau pois a = 0."); } else { delta = double((b * b) - (4 * a * c)); if (delta < 0) { printf("\nNao e possivel calcular as raizes pois delta < 0, e as raizes sao imaginarias."); } else { raiz = sqrt(delta); x1 = (-b + raiz) / 2.0 * a; x2 = (-b - raiz) / 2.0 * a; printf("\nAs raizes da sua equacao sao: "); printf("\nX1 = %.4f & X2 = %.4f.", x1, x2); printf("\n Seu delta e igual a %f", delta); if (delta == 0) { printf("\n\nSuas raizes sao iguais pois o delta e igual a 0."); } } } }
#include <stdio.h> #include<stdlib.h> /*Estructura llamada alumno para los dato de 3 alumnos y mostrar cual tiene el mejor promedio Elaborado por: Viviana Rojas Ruiz*/ struct alumno{ char nombre[20]; int edad; float promedio; }estudiantes[3],*pestu=estudiantes,aux[3],*paux=aux; int main() { printf("Ingrese Datos de los Estudiantes:\n"); for(int i=0;i<3;i++){ fflush stdin; printf("\n%i.Nombre: ",i+1); gets((pestu+i)->nombre); printf("%i.Edad: ",i+1); scanf("%d",&(pestu+i)->edad); printf("%i.Promedio: ",i+1); scanf("%f",&(pestu+i)->promedio); } printf("\n<<<<<<<Mostrando datos del alumno Mejor Promedio>>>>>>>\n"); if(((pestu+0)->promedio > (pestu+1)->promedio)&&((pestu+0)->promedio > (pestu+2)->promedio)){ printf("Nombre: %s",(pestu+0)->nombre); printf("\nEdad: %d",(pestu+0)->edad); printf("\nPromedio: %.1f",(pestu+0)->promedio); } if(((pestu+1)->promedio > (pestu+2)->promedio) && ((pestu+1)->promedio > (pestu+0)->promedio)){ printf("Nombre: %s",(pestu+1)->nombre); printf("\nEdad: %d",(pestu+1)->edad); printf("\nPromedio: %.1f",(pestu+1)->promedio); } if (((pestu+2)->promedio > (pestu+1)->promedio)&&((pestu+2)->promedio > (pestu+0)->promedio)){ printf("Nombre: %s",(pestu+2)->nombre); printf("\nEdad: %d",(pestu+2)->edad); printf("\nPromedio: %.1f",(pestu+2)->promedio); } return 0; }
#ifndef ACTOR_H #define ACTOR_H #include "Lib.h" namespace gnGame { class IScene; /// <summary> /// 方向(向いている方向, 移動する方向) /// </summary> enum class Direction { Up, Down, Left, Right, }; // マップとの当たり判定ようの構造体 struct IntersectPoint { static const int Size = 2; vector<Vector2> right; vector<Vector2> left; vector<Vector2> top; vector<Vector2> bottom; IntersectPoint() : right(Size) , left(Size) , top(Size) , bottom(Size) {} }; // キャラクターの基底クラス class Actor : public Object { public: Actor(); ~Actor() = default; virtual void onStart() = 0; virtual void onUpdate() = 0; // マップとの当たり判定 virtual Vector2 intersectTileMap() = 0; bool fallScreen(float _fallBorder); // 初期位置を設定 void initPosition(const Vector2& _initPos) { velocity = Vector2::Zero; this->transform.pos.setPos(_initPos); } // 加速ベクトルを取得する inline const Vector2& getVelocity() { return velocity; } protected: Vector2 velocity; // 速度 Bounds bounds; // バウンディングボックス IntersectPoint intersectPoint; // 床との当たり判定 bool isFlip = false; // 画像が判定するかのフラグ }; } #endif // !ACTOR_H
#ifndef WEAPON_H #define WEAPON_H #include<iostream> #include<string> #include<sstream> using std::string; using std::stringstream; using std::endl; enum WeaponType {sword, axe, lance, bow, anima, light, dark, staff}; class Character; class Weapon { private: int *id; static int increment; string name; int damages; int hit; int range; int crit; int worth; int uses; protected: public: const WeaponType TYPE; Weapon(string name="DEFAULT", int damages=1, int hit=85, int range=1, int crit=0, int worth=1, int uses = 40, WeaponType type=sword); virtual ~Weapon(); Weapon(const Weapon& other); Weapon& operator=(const Weapon& other); bool operator==(const Weapon& w)const; int getId()const; string getName()const; int getDamages()const; int getHit()const; int getRange()const; int getCrit()const; int getWorth()const; int getDurability()const; void setName(const string name); void setHit(const int hit); void setRange(const int range); void setCrit(const int crit); void setWorth(const int worth); void setDurability(const int uses); virtual Weapon* clone()const=0; void decrement(); virtual float strategyAccuracy(const Character& att, const Character& def)const=0; virtual float strategyDamages(const Character& att, const Character& def)const=0; string str()const; }; #endif // WEAPON_H
/*==================================================================== Copyright(c) 2018 Adam Rankin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ====================================================================*/ #pragma once // Common includes #include "DeviceResources.h" #include "StepTimer.h" // STL includes #include <vector> // WinRT includes #include <collection.h> namespace HoloIntervention { class IConfigurable; class IEngineComponent; class ILocatable; class Debug; namespace Physics { class PhysicsAPI; } namespace UI { class Icons; class Icon; } namespace System { class GazeSystem; class ImagingSystem; class NetworkSystem; class NotificationSystem; class RegistrationSystem; class SplashSystem; class TaskSystem; class ToolSystem; } namespace Input { class SpatialInput; class VoiceInput; } namespace Rendering { class ModelRenderer; class NotificationRenderer; class SliceRenderer; class MeshRenderer; class VolumeRenderer; } namespace Network { class IGTConnector; } namespace Sound { class SoundAPI; } // Updates, renders, and presents holographic content using Direct3D. class HoloInterventionCore : public DX::IDeviceNotify { public: HoloInterventionCore(const std::shared_ptr<DX::DeviceResources>& deviceResources); ~HoloInterventionCore(); // Sets the holographic space. This is our closest analogue to setting a new window // for the app. void SetHolographicSpace(Windows::Graphics::Holographic::HolographicSpace^ holographicSpace); // Starts the holographic frame and updates the content. Windows::Graphics::Holographic::HolographicFrame^ Update(); // Renders holograms, including world-locked content. bool Render(Windows::Graphics::Holographic::HolographicFrame^ holographicFrame); // Handle saving and loading of app state owned by AppMain. Concurrency::task<bool> SaveAppStateAsync(); Concurrency::task<bool> LoadAppStateAsync(); // Global access to the current frame number uint64 GetCurrentFrameNumber() const; // IDeviceNotify virtual void OnDeviceLost(); virtual void OnDeviceRestored(); // Locatable components void RegisterLocatable(ILocatable*); void UnregisterLocatable(ILocatable*); void RegisterConfigurable(IConfigurable*); void UnregisterConfigurable(IConfigurable*); protected: // Asynchronously creates resources for new holographic cameras. void OnCameraAdded(Windows::Graphics::Holographic::HolographicSpace^ sender, Windows::Graphics::Holographic::HolographicSpaceCameraAddedEventArgs^ args); // Synchronously releases resources for holographic cameras that are no longer attached to the system. void OnCameraRemoved(Windows::Graphics::Holographic::HolographicSpace^ sender, Windows::Graphics::Holographic::HolographicSpaceCameraRemovedEventArgs^ args); // Used to notify the app when the positional tracking state changes. void OnLocatabilityChanged(Windows::Perception::Spatial::SpatialLocator^ sender, Platform::Object^ args); // Clears event registration state. Used when changing to a new HolographicSpace and when tearing down AppMain. void UnregisterHolographicEventHandlers(); // Check for any voice input commands void RegisterVoiceCallbacks(); // Set the focus point depending on the state of all the systems void SetHolographicFocusPoint(Windows::Graphics::Holographic::HolographicFramePrediction^ prediction, Windows::Graphics::Holographic::HolographicFrame^ holographicFrame, Windows::Perception::Spatial::SpatialCoordinateSystem^ currentCoordinateSystem, Windows::UI::Input::Spatial::SpatialPointerPose^ headPose); // Read/write the configuration to file Concurrency::task<bool> WriteConfigurationAsync(); Concurrency::task<bool> ReadConfigurationAsync(); protected: // Lists of components std::vector<IEngineComponent*> m_engineComponents; std::vector<IConfigurable*> m_configurables; std::vector<ILocatable*> m_locatables; // Locatability icon uint64 m_locatabilityMessage = INVALID_TOKEN; std::shared_ptr<UI::Icon> m_locatabilityIcon = nullptr; // Engine components std::unique_ptr<Rendering::ModelRenderer> m_modelRenderer; std::unique_ptr<Rendering::NotificationRenderer> m_notificationRenderer; std::unique_ptr<Rendering::SliceRenderer> m_sliceRenderer; std::unique_ptr<Rendering::MeshRenderer> m_meshRenderer; std::unique_ptr<Rendering::VolumeRenderer> m_volumeRenderer; std::unique_ptr<Debug> m_debug; std::unique_ptr<UI::Icons> m_icons; // Event handlers std::unique_ptr<Input::SpatialInput> m_spatialInput; std::unique_ptr<Input::VoiceInput> m_voiceInput; // Engine state std::atomic_bool m_engineReady = false; std::atomic_bool m_engineUserEnabled = true; // Cached pointer to device resources. std::shared_ptr<DX::DeviceResources> m_deviceResources; // Render loop timer. DX::StepTimer m_timer; // Represents the holographic space around the user. Windows::Graphics::Holographic::HolographicSpace^ m_holographicSpace; // SpatialLocator that is attached to the primary camera. Windows::Perception::Spatial::SpatialLocator^ m_locator; // A reference frame attached to the holographic camera. Windows::Perception::Spatial::SpatialLocatorAttachedFrameOfReference^ m_attachedReferenceFrame; // Event registration tokens. Windows::Foundation::EventRegistrationToken m_cameraAddedToken; Windows::Foundation::EventRegistrationToken m_cameraRemovedToken; Windows::Foundation::EventRegistrationToken m_locatabilityChangedToken; uint64 m_trackedFrameReceivedToken; // Store the current state of locatability Windows::Perception::Spatial::SpatialLocatability m_locatability; // System pointers std::shared_ptr<System::NetworkSystem> m_networkSystem; std::unique_ptr<System::GazeSystem> m_gazeSystem; std::unique_ptr<System::ImagingSystem> m_imagingSystem; std::unique_ptr<System::NotificationSystem> m_notificationSystem; std::unique_ptr<System::RegistrationSystem> m_registrationSystem; std::unique_ptr<System::SplashSystem> m_splashSystem; std::unique_ptr<System::TaskSystem> m_taskSystem; std::unique_ptr<System::ToolSystem> m_toolSystem; // Physics std::unique_ptr<Physics::PhysicsAPI> m_physicsAPI; // Sound std::unique_ptr<Sound::SoundAPI> m_soundAPI; }; }
#include<iostream> #include<vector> #include<string> using namespace std; int main(){ //input vector<string> date; string temp; cin>>temp; while(temp!="."&&date.size()<15){ date.push_back(temp); cin>>temp; } //deal with and output if(date.size()>=14){ cout<<date[1]<<" and "<<date[13]<<" are inviting you to dinner..."; }else if(date.size()>=2){ cout<<date[1]<<" is the only one for you..."; }else{ cout<<"Momo... No one is for you ..."; } return 0; }
//Display the help int fix_help(void) { //Display the help cout << "Cover Fix " << endl; cout << "Version: " << _VERSION << endl; cout << "Add all positions on the coverage matrix that has zero depth." << endl << endl; //Display the usage cout << "Usage: covertools fix --bed <BED_FILE> --cover <COVER_INPUT> --out <COVER_OUTPUT>" << endl << endl; //Display the mandatory options cout << "Mandatory options: " << endl; cout << " --bed " << "Path to the BED file with the delimited regions." << endl; cout << " --cover " << "Path to the input coverage file." << endl; cout << " --out " << "Path to the output coverage file." << endl; //Exit return 0; }