Setup basic utils structure

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
Nic0Nic0Nii 1 year ago
parent afca1c8701
commit fce397b68b
  1. 3
      .vscode/settings.json
  2. 6
      C++/scripts/md5
  3. BIN
      C++ProjectTemplate
  4. 8
      main.cpp
  5. 1
      pixelGameEngine.cpp
  6. BIN
      pixelGameEngine.o
  7. 2
      sig
  8. 18
      utils.cpp
  9. 20
      utils.h

@ -60,5 +60,6 @@
"cinttypes": "cpp",
"typeinfo": "cpp",
"strstream": "cpp"
}
},
"C_Cpp.errorSquiggles": "enabledIfIncludesResolve"
}

@ -1,7 +1,7 @@
build.sh:c073187e65d0e23aa77aa94af4ec6382 -
commit.sh:1af81bf417dfb932284d8a14fdd10657 -
debug.sh:849488515cab075948653c15eec4177b -
debug.sh:8125f303032b6cbc137223df63d10096 -
lines.sh:3b907786f7fc9204025993016c9080de -
release.sh:0ab321c3fa2f1a1b2f03b1aec3bce816 -
release.sh:b1ce8461a303e8e7aa9ed74259db3873 -
temp:d41d8cd98f00b204e9800998ecf8427e -
web.sh:4bbe9c5710a0ae4289468c3f7f340ff1 -
web.sh:dd7eec9825587db99063877da2839506 -

Binary file not shown.

@ -1,4 +1,5 @@
#include "pixelGameEngine.h"
#include "utils.h"
using namespace olc;
@ -60,9 +61,8 @@ struct Data{
int main()
{
Example demo;
if (demo.Construct(640, 480, 4, 4))
demo.Start();
utils::PowMod(5,117,19);
utils::PowMod(5,117,19);
std::cout<<"Works!"<<std::endl;
return 0;
}

@ -1,2 +1,3 @@
#define OLC_PGE_APPLICATION
#define OLC_PGE_HEADLESS
#include "pixelGameEngine.h"

Binary file not shown.

2
sig

@ -3,7 +3,7 @@ export AUTO_UPDATE=true
source utils/define.sh
define PROJECT_NAME "C++ProjectTemplate"
define CUSTOM_PARAMS "-std=c++17 -lX11 -lGL -lpthread -lpng -lstdc++fs -I/usr/include/lua5.3"
define CUSTOM_PARAMS "-std=c++17 -lX11 -lpthread -lpng -lstdc++fs -I/usr/include/lua5.3"
define LANGUAGE "C++"
source utils/main.sh

@ -0,0 +1,18 @@
#include "utils.h"
#include <cmath>
std::map<internal::PowModStruct,int>utils::mapping;
int utils::PowMod(int a,int b, int mod){
int shift=0;
for(int n=1;n<=b;n*=2){
if(utils::mapping.find({a,n,mod})!=utils::mapping.end()){
std::cout<<internal::PowModStruct{a,n,mod}<<"="<<utils::mapping[{a,n,mod}]<<std::endl;
continue;
}
std::cout<<std::fmod(std::pow(double(a),double(n)),double(mod))<<std::endl;
utils::mapping[{a,n,mod}]=std::fmod(std::pow(double(a),double(n)),double(mod));
shift++;
}
return 0;
}

@ -0,0 +1,20 @@
#pragma once
#include <map>
#include <iostream>
namespace internal{
struct PowModStruct{
int a,b,mod;
friend std::ostream& operator << (std::ostream& os, const internal::PowModStruct& rhs) { os << rhs.a << "^" << rhs.b << "%" << rhs.mod; return os; };
bool operator<(const internal::PowModStruct&rhs)const{return a<rhs.a||b<rhs.b||mod<rhs.mod;};
};
}
class utils{
utils()=delete;
utils(utils&utils)=delete;
static std::map<internal::PowModStruct,int>mapping;
public:
//a^b % mod
static int PowMod(int a,int b,int mod);
};
Loading…
Cancel
Save