blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 117 | path stringlengths 3 268 | src_encoding stringclasses 34
values | length_bytes int64 6 4.23M | score float64 2.52 5.19 | int_score int64 3 5 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | text stringlengths 13 4.23M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
595e67ad2874bc5047a45c63249d14cf75ceb51e | C++ | kmanghat/Kattis-Solutions | /permutationEncryption.cpp | UTF-8 | 914 | 2.9375 | 3 | [] | no_license | #include <bits/stdc++.h>
using namespace std;
int roundUp(int numToround, int multiple)
{
int remainder = numToround % multiple;
if(remainder == 0)
return numToround;
return numToround + multiple -remainder;
}
int main()
{
int n;
while(cin>>n && n != 0)
{
vector<int> perm;
vector<string> msgholder;
int p;
for(int i= 0; i < n; i++)
{
cin>>p;
perm.push_back(p-1);
}
string msg;
cin.ignore();
getline(cin,msg);
int len = msg.size();
int padding = roundUp(len, n) - len;
msg.append(padding,' ');
len += padding;
int numStr = len/n;
for(int i = 0; i < numStr ; i++)
{
string temp = msg.substr(i*n,n);
msgholder.push_back(temp);
temp.clear();
}
cout<<"'";
for(int i = 0 ; i < msgholder.size(); i++)
{
for(int j = 0 ; j < perm.size(); j++)
{
cout<<msgholder[i][perm[j]];
}
}
cout<<"'"<<endl;
}
return 0;
}
| true |
aaa944fbaa3cfab928db7c70d9c78faf565af37c | C++ | mzry1992/workspace | /OJ/CDOJ/POJ3608.cpp | GB18030 | 6,646 | 2.828125 | 3 | [] | no_license | #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps = 1e-6;
struct Point
{
double x,y;
Point(){}
Point(double _x ,double _y)
{
x = _x;
y = _y;
}
Point(Point a,Point b)
{
x = b.x-a.x;
y = b.y-a.y;
}
};
struct Line
{
Point s,e;
Line(){}
Line(const Point & a ,const Point &b)
{
s = a;
e = b;
}
};
int n0,n1;
Point pa[1001],pb[1001];
double res;
inline double Xmult(Point a,Point b)
{
return a.x*b.y-a.y*b.x;
}
inline double Xmult(Point a,Point b,Point c)
{
return Xmult(Point(b.x-a.x,b.y-a.y),Point(c.x-a.x,c.y-a.y));
}
inline double Distance(Point a,Point b)
{
return (sqrt((b.x-a.x)*(b.x-a.x)+(b.y-a.y)*(b.y-a.y)));
}
inline double Distance(Point a,Line b) //㵽߶
{
Point t = a;
t.x += b.s.y-b.e.y;
t.y += b.e.x-b.s.x;
if (Xmult(b.s,t,a)*Xmult(b.e,t,a) > eps)
return min(Distance(a,b.s),Distance(a,b.e));
return fabs(Xmult(a,b.e,b.s))/Distance(b.s,b.e);
}
inline double Distance(Line a,Line b) //ƽ߶
{
return min(min(Distance(a.s,b),Distance(a.e,b)),min(Distance(b.s,a),Distance(b.e,a)));
}
void AntiPodal(Point a,Point b)
{
if (res > Distance(a,b)) res = Distance(a,b);
}
void AntiPodal(Point a,Line b)
{
if (res > Distance(a,b)) res = Distance(a,b);
}
void AntiPodal(Line a,Line b)
{
if (res > Distance(a,b)) res = Distance(a,b);
}
void RotatingCalipers(Point pa[],Point pb[],int n0,int n1)
{
int p0,p1,q0,q1,tp0,tp1;
double xmult;
Point v0,v1,now;
p0 = p1 = 1;
for (int i = 0;i < n0;i++)
if ((pa[p0].y > pa[i].y) || ((pa[p0].y == pa[i].y) && (pa[p0].x > pa[i].x))) p0 = i;
for (int i = 0;i < n1;i++)
if ((pb[p1].y < pb[i].y) || ((pb[p1].y == pb[i].y) && (pb[p1].x < pb[i].x))) p1 = i;
AntiPodal(pa[p0],pb[p1]);
tp0 = p0;
tp1 = p1;
while (true)
{
q0 = (p0+1)%n0;
q1 = (p1+1)%n1;
v0 = Point(pa[q0].x-pa[p0].x,pa[q0].y-pa[p0].y);
v1 = Point(pb[q1].x-pb[p1].x,pb[q1].y-pb[p1].y);
xmult = Xmult(v0,v1);
if (xmult < -eps)
{
//cout << "A" << endl;
AntiPodal(pa[q0],pb[p1]);
AntiPodal(pb[p1],Line(pa[p0],pa[q0]));
p0 = q0;
}
else if (xmult > eps)
{
//cout << "B" << endl;
AntiPodal(pa[p0],pb[q1]);
AntiPodal(pa[p0],Line(pb[p1],pb[q1]));
p1 = q1;
}
else
{
//cout << "C" << endl;
AntiPodal(pa[p0],pb[q1]);
AntiPodal(pa[q0],pb[p1]);
AntiPodal(pa[q0],pb[q1]);
AntiPodal(Line(pa[p0],pa[q0]),Line(pb[p1],pb[q1]));
p0 = q0;
p1 = q1;
}
if (p0 != tp0) continue;
if (p1 != tp1) continue;
break;
}
}
bool GrahamScanCmp(Point p1,Point p2)
{
if (p1.x == p2.x) return p1.y > p2.y;
else return p1.x > p2.x;
}
inline int is_left(Point a,Point b,Point c)
{
Point p1,p2;
p1 = Point(b.x-a.x,b.y-a.y);
p2 = Point(c.x-b.x,c.y-b.y);
return Xmult(p1,p2);
}
Point tp[1001];
int h[1001];
int GrahamScan(Point p[],int n)
{
int top,sp = 0;
for (int i = 0;i < n;i++) tp[i] = p[i];
sort(tp,tp+n,GrahamScanCmp);
for (int i = 0;i < n;)
if (sp < 2 || is_left(tp[h[sp-2]],tp[h[sp-1]],tp[i]) >= 0) h[sp++] = i++;
else --sp;
top = sp-1;
for (int i = n-2;i >= 0;)
if (sp < top+2 || is_left(tp[h[sp-2]],tp[h[sp-1]],tp[i]) >= 0) h[sp++] = i--;
else --sp;
for (int i = 0;i < sp;i++)
p[i] = tp[h[i]];
return sp-1;
}
int main()
{
while (scanf("%d%d",&n0,&n1) != EOF)
{
for (int i = 0;i < n0;i++)
scanf("%lf%lf",&pa[i].x,&pa[i].y);
for (int i = 0;i < n1;i++)
scanf("%lf%lf",&pb[i].x,&pb[i].y);
n0 = GrahamScan(pa,n0);
n1 = GrahamScan(pb,n1);
res = 1e15;
if (n0 >= 3 && n1 >= 3)
{
RotatingCalipers(pa,pb,n0,n1);
RotatingCalipers(pb,pa,n1,n0);
printf("%.4f\n",res);
}
else
{
if (n0 == 1)
{
for (int i = 0;i < n1;i++)
if (res > Distance(pa[0],pb[i]))
res = Distance(pa[0],pb[i]);
for (int i = 0;i < n1;i++)
if (res > Distance(pa[0],Line(pb[i],pb[(i+1)%n1])))
res = Distance(pa[0],Line(pb[i],pb[(i+1)%n1]));
}
else if (n0 == 2)
{
for (int i = 0;i < n0;i++)
for (int j = 0;j < n1;j++)
if (res > Distance(pa[i],pb[j]))
res = Distance(pa[i],pb[j]);
for (int i = 0;i < n1;i++)
if (res > Distance(pb[i],Line(pa[0],pa[1])))
res = Distance(pb[i],Line(pa[0],pa[1]));
for (int i = 0;i < n1;i++)
if (res > Distance(Line(pa[0],pa[1]),Line(pb[i],pb[(i+1)%n1])))
res = Distance(Line(pa[0],pa[1]),Line(pb[i],pb[(i+1)%n1]));
}
else if (n1 == 1)
{
for (int i = 0;i < n0;i++)
if (res > Distance(pb[0],pa[i]))
res = Distance(pb[0],pa[i]);
for (int i = 0;i < n0;i++)
if (res > Distance(pb[0],Line(pa[i],pa[(i+1)%n0])))
res = Distance(pb[0],Line(pa[i],pa[(i+1)%n0]));
}
else if (n1 == 2)
{
for (int i = 0;i < n1;i++)
for (int j = 0;j < n0;j++)
if (res > Distance(pb[i],pa[j]))
res = Distance(pb[i],pa[j]);
for (int i = 0;i < n0;i++)
if (res > Distance(pa[i],Line(pb[0],pb[1])))
res = Distance(pa[i],Line(pb[0],pb[1]));
for (int i = 0;i < n0;i++)
if (res > Distance(Line(pb[0],pb[1]),Line(pa[i],pa[(i+1)%n0])))
res = Distance(Line(pb[0],pb[1]),Line(pa[i],pa[(i+1)%n0]));
}
printf("%.4f\n",res);
}
}
}
| true |
64a139a265bc98127cef423bfd29d3e266e444cc | C++ | InGen6400/Neural_Practice | /NeuralPractice/neuron.cpp | SHIFT_JIS | 768 | 2.828125 | 3 | [] | no_license | #include "stdafx.h"
#include "neuron.h"
#include <math.h>
#include <random>
void Neuron_New(Neuron *neuron, int count, int prevCount) {
neuron = (Neuron*)calloc(count + 1, sizeof(Neuron));
neuron->wheight = (double*)calloc(prevCount, sizeof(double));
}
void Neuron_Init(Neuron *neuron, int count, int prevCount) {
int i;
//
std::random_device rnd1;
std::mt19937 rnd(rnd1());
std::uniform_real_distribution<> rand01(0, 1);
for (i = 0; i < prevCount; i++) {
neuron->wheight[i] = rand01(rnd);//0~1̃ZkcCX^
}
}
//VOCh
double sigmoid(double input) {
return 1 / (1 + exp(-input));
}
//VOCh̔
double d_sigmoid(double input) {
return (1 - sigmoid(input))*sigmoid(input);
} | true |
8749e08c5edb18b48b290d5201410461914829b0 | C++ | roche-emmanuel/singularity | /sources/wx/interface/wxApp.h | UTF-8 | 19,277 | 2.75 | 3 | [] | no_license | #ifndef _WX_APP_H_BASE_
#define _WX_APP_H_BASE_
enum
{
wxPRINT_WINDOWS = 1,
wxPRINT_POSTSCRIPT = 2
};
class wxAppConsole : public wxEvtHandler, public wxEventFilter
{
public:
// ctor and dtor
//wxAppConsole();
//virtual ~wxAppConsole();
// the virtual functions which may/must be overridden in the derived class
// -----------------------------------------------------------------------
// This is the very first function called for a newly created wxApp object,
// it is used by the library to do the global initialization. If, for some
// reason, you must override it (instead of just overriding OnInit(), as
// usual, for app-specific initializations), do not forget to call the base
// class version!
//virtual bool Initialize(int& argc, wxChar **argv);
// This gives wxCocoa a chance to call OnInit() with a memory pool in place
virtual bool CallOnInit() { return OnInit(); }
// Called before OnRun(), this is a good place to do initialization -- if
// anything fails, return false from here to prevent the program from
// continuing. The command line is normally parsed here, call the base
// class OnInit() to do it.
virtual bool OnInit();
// This is the replacement for the normal main(): all program work should
// be done here. When OnRun() returns, the programs starts shutting down.
virtual int OnRun();
// This is called by wxEventLoopBase::SetActive(): you should put the code
// which needs an active event loop here.
// Note that this function is called whenever an event loop is activated;
// you may want to use wxEventLoopBase::IsMain() to perform initialization
// specific for the app's main event loop.
//virtual void OnEventLoopEnter(wxEventLoopBase* loop) {}
// This is only called if OnInit() returned true so it's a good place to do
// any cleanup matching the initializations done there.
virtual int OnExit();
// This is called by wxEventLoopBase::OnExit() for each event loop which
// is exited.
//virtual void OnEventLoopExit(wxEventLoopBase* loop) {}
// This is the very last function called on wxApp object before it is
// destroyed. If you override it (instead of overriding OnExit() as usual)
// do not forget to call the base class version!
virtual void CleanUp();
// Called when a fatal exception occurs, this function should take care not
// to do anything which might provoke a nested exception! It may be
// overridden if you wish to react somehow in non-default way (core dump
// under Unix, application crash under Windows) to fatal program errors,
// however extreme care should be taken if you don't want this function to
// crash.
virtual void OnFatalException() { }
// Called from wxExit() function, should terminate the application a.s.a.p.
virtual void Exit();
// application info: name, description, vendor
// -------------------------------------------
// NB: all these should be set by the application itself, there are no
// reasonable default except for the application name which is taken to
// be argv[0]
// set/get the application name
wxString GetAppName() const;
void SetAppName(const wxString& name) { m_appName = name; }
// set/get the application display name: the display name is the name
// shown to the user in titles, reports, etc while the app name is
// used for paths, config, and other places the user doesn't see
//
// by default the display name is the same as app name or a capitalized
// version of the program if app name was not set neither but it's
// usually better to set it explicitly to something nicer
wxString GetAppDisplayName() const;
void SetAppDisplayName(const wxString& name) { m_appDisplayName = name; }
// set/get the app class name
wxString GetClassName() const { return m_className; }
void SetClassName(const wxString& name) { m_className = name; }
// set/get the vendor name
const wxString& GetVendorName() const { return m_vendorName; }
void SetVendorName(const wxString& name) { m_vendorName = name; }
// set/get the vendor display name: the display name is shown
// in titles/reports/dialogs to the user, while the vendor name
// is used in some areas such as wxConfig, wxStandardPaths, etc
const wxString& GetVendorDisplayName() const
{
return m_vendorDisplayName.empty() ? GetVendorName()
: m_vendorDisplayName;
}
void SetVendorDisplayName(const wxString& name)
{
m_vendorDisplayName = name;
}
// cmd line parsing stuff
// ----------------------
// all of these methods may be overridden in the derived class to
// customize the command line parsing (by default only a few standard
// options are handled)
//
// you also need to call wxApp::OnInit() from YourApp::OnInit() for all
// this to work
// miscellaneous customization functions
// -------------------------------------
// create the app traits object to which we delegate for everything which
// either should be configurable by the user (then he can change the
// default behaviour simply by overriding CreateTraits() and returning his
// own traits object) or which is GUI/console dependent as then wxAppTraits
// allows us to abstract the differences behind the common facade
//wxAppTraits *GetTraits();
// this function provides safer access to traits object than
// wxTheApp->GetTraits() during startup or termination when the global
// application object itself may be unavailable
//
// of course, it still returns NULL in this case and the caller must check
// for it
//static wxAppTraits *GetTraitsIfExists();
// returns the main event loop instance, i.e. the event loop which is started
// by OnRun() and which dispatches all events sent from the native toolkit
// to the application (except when new event loops are temporarily set-up).
// The returned value maybe NULL. Put initialization code which needs a
// non-NULL main event loop into OnEventLoopEnter().
//wxEventLoopBase* GetMainLoop() const
// { return m_mainLoop; }
// event processing functions
// --------------------------
// Implement the inherited wxEventFilter method but just return -1 from it
// to indicate that default processing should take place.
virtual int FilterEvent(wxEvent& event);
// return true if we're running event loop, i.e. if the events can
// (already) be dispatched
static bool IsMainLoopRunning();
// execute the functor to handle the given event
//
// this is a generalization of HandleEvent() below and the base class
// implementation of CallEventHandler() still calls HandleEvent() for
// compatibility for functors which are just wxEventFunctions (i.e. methods
// of wxEvtHandler)
// virtual void CallEventHandler(wxEvtHandler *handler,
// wxEventFunctor& functor,
// wxEvent& event) const;
// call the specified handler on the given object with the given event
//
// this method only exists to allow catching the exceptions thrown by any
// event handler, it would lead to an extra (useless) virtual function call
// if the exceptions were not used, so it doesn't even exist in that case
// virtual void HandleEvent(wxEvtHandler *handler,
// wxEventFunction func,
// wxEvent& event) const;
// Called when an unhandled C++ exception occurs inside OnRun(): note that
// the main event loop has already terminated by now and the program will
// exit, if you need to really handle the exceptions you need to override
// OnExceptionInMainLoop()
virtual void OnUnhandledException();
// Function called if an uncaught exception is caught inside the main
// event loop: it may return true to continue running the event loop or
// false to stop it (in the latter case it may rethrow the exception as
// well)
virtual bool OnExceptionInMainLoop();
// pending events
// --------------
// IMPORTANT: all these methods conceptually belong to wxEventLoopBase
// but for many reasons we need to allow queuing of events
// even when there's no event loop (e.g. in wxApp::OnInit);
// this feature is used e.g. to queue events on secondary threads
// or in wxPython to use wx.CallAfter before the GUI is initialized
// process all events in the m_handlersWithPendingEvents list -- it is necessary
// to call this function to process posted events. This happens during each
// event loop iteration in GUI mode but if there is no main loop, it may be
// also called directly.
virtual void ProcessPendingEvents();
// check if there are pending events on global pending event list
bool HasPendingEvents() const;
// temporary suspends processing of the pending events
void SuspendProcessingOfPendingEvents();
// resume processing of the pending events previously stopped because of a
// call to SuspendProcessingOfPendingEvents()
void ResumeProcessingOfPendingEvents();
// called by ~wxEvtHandler to (eventually) remove the handler from the list of
// the handlers with pending events
void RemovePendingEventHandler(wxEvtHandler* toRemove);
// adds an event handler to the list of the handlers with pending events
void AppendPendingEventHandler(wxEvtHandler* toAppend);
// moves the event handler from the list of the handlers with pending events
//to the list of the handlers with _delayed_ pending events
void DelayPendingEventHandler(wxEvtHandler* toDelay);
// deletes the current pending events
void DeletePendingEvents();
// delayed destruction
// -------------------
// If an object may have pending events for it, it shouldn't be deleted
// immediately as this would result in a crash when trying to handle these
// events: instead, it should be scheduled for destruction and really
// destroyed only after processing all pending events.
//
// Notice that this is only possible if we have a running event loop,
// otherwise the object is just deleted directly by ScheduleForDestruction()
// and IsScheduledForDestruction() always returns false.
// schedule the object for destruction in the near future
void ScheduleForDestruction(wxObject *object);
// return true if the object is scheduled for destruction
bool IsScheduledForDestruction(wxObject *object) const;
// wxEventLoop-related methods
// ---------------------------
// all these functions are forwarded to the corresponding methods of the
// currently active event loop -- and do nothing if there is none
virtual bool Pending();
virtual bool Dispatch();
virtual int MainLoop();
virtual void ExitMainLoop();
bool Yield(bool onlyIfNeeded = false);
virtual void WakeUpIdle();
// this method is called by the active event loop when there are no events
// to process
//
// by default it generates the idle events and if you override it in your
// derived class you should call the base class version to ensure that idle
// events are still sent out
virtual bool ProcessIdle();
// this virtual function is overridden in GUI wxApp to always return true
// as GUI applications always have an event loop -- but console ones may
// have it or not, so it simply returns true if already have an event loop
// running but false otherwise
virtual bool UsesEventLoop() const;
// debugging support
// -----------------
// this function is called when an assert failure occurs, the base class
// version does the normal processing (i.e. shows the usual assert failure
// dialog box)
//
// the arguments are the location of the failed assert (func may be empty
// if the compiler doesn't support C99 __FUNCTION__), the text of the
// assert itself and the user-specified message
virtual void OnAssertFailure(const wxChar *file,
int line,
const wxChar *func,
const wxChar *cond,
const wxChar *msg);
// old version of the function without func parameter, for compatibility
// only, override OnAssertFailure() in the new code
virtual void OnAssert(const wxChar *file,
int line,
const wxChar *cond,
const wxChar *msg);
// check that the wxBuildOptions object (constructed in the application
// itself, usually the one from wxIMPLEMENT_APP() macro) matches the build
// options of the library and abort if it doesn't
static bool CheckBuildOptions(const char *optionsSignature,
const char *componentName);
// implementation only from now on
// -------------------------------
// helpers for dynamic wxApp construction
//static void SetInitializerFunction(wxAppInitializerFunction fn) { ms_appInitFn = fn; }
//static wxAppInitializerFunction GetInitializerFunction() { return ms_appInitFn; }
// accessors for ms_appInstance field (external code might wish to modify
// it, this is why we provide a setter here as well, but you should really
// know what you're doing if you call it), wxTheApp is usually used instead
// of GetInstance()
static wxAppConsole *GetInstance() { return ms_appInstance; }
static void SetInstance(wxAppConsole *app) { ms_appInstance = app; }
};
class wxApp : public wxAppConsole
{
public:
//wxApp();
//virtual ~wxApp();
// the virtual functions which may/must be overridden in the derived class
// -----------------------------------------------------------------------
// very first initialization function
//
// Override: very rarely
//virtual bool Initialize(int& argc, wxChar **argv);
// a platform-dependent version of OnInit(): the code here is likely to
// depend on the toolkit. default version does nothing.
//
// Override: rarely.
virtual bool OnInitGui();
// called to start program execution - the default version just enters
// the main GUI loop in which events are received and processed until
// the last window is not deleted (if GetExitOnFrameDelete) or
// ExitMainLoop() is called. In console mode programs, the execution
// of the program really starts here
//
// Override: rarely in GUI applications, always in console ones.
virtual int OnRun();
// a matching function for OnInit()
virtual int OnExit();
// very last clean up function
//
// Override: very rarely
virtual void CleanUp();
// the worker functions - usually not used directly by the user code
// -----------------------------------------------------------------
// safer alternatives to Yield(), using wxWindowDisabler
virtual bool SafeYield(wxWindow *win, bool onlyIfNeeded);
virtual bool SafeYieldFor(wxWindow *win, long eventsToProcess);
// this virtual function is called in the GUI mode when the application
// becomes idle and normally just sends wxIdleEvent to all interested
// parties
//
// it should return true if more idle events are needed, false if not
virtual bool ProcessIdle();
// override base class version: GUI apps always use an event loop
virtual bool UsesEventLoop() const { return true; }
// top level window functions
// --------------------------
// return true if our app has focus
virtual bool IsActive() const { return m_isActive; }
// set the "main" top level window
void SetTopWindow(wxWindow *win) { m_topWindow = win; }
// return the "main" top level window (if it hadn't been set previously
// with SetTopWindow(), will return just some top level window and, if
// there are none, will return NULL)
virtual wxWindow *GetTopWindow() const;
// control the exit behaviour: by default, the program will exit the
// main loop (and so, usually, terminate) when the last top-level
// program window is deleted. Beware that if you disable this behaviour
// (with SetExitOnFrameDelete(false)), you'll have to call
// ExitMainLoop() explicitly from somewhere.
void SetExitOnFrameDelete(bool flag)
{ m_exitOnFrameDelete = flag ? Yes : No; }
bool GetExitOnFrameDelete() const
{ return m_exitOnFrameDelete == Yes; }
// display mode, visual, printing mode, ...
// ------------------------------------------------------------------------
// Get display mode that is used use. This is only used in framebuffer
// wxWin ports (such as wxMGL or wxDFB).
//virtual wxVideoMode GetDisplayMode() const;
// Set display mode to use. This is only used in framebuffer wxWin
// ports (such as wxMGL or wxDFB). This method should be called from
// wxApp::OnInitGui
//virtual bool SetDisplayMode(const wxVideoMode& WXUNUSED(info)) { return true; }
// set use of best visual flag (see below)
void SetUseBestVisual( bool flag, bool forceTrueColour = false )
{ m_useBestVisual = flag; m_forceTrueColour = forceTrueColour; }
bool GetUseBestVisual() const { return m_useBestVisual; }
// set/get printing mode: see wxPRINT_XXX constants.
//
// default behaviour is the normal one for Unix: always use PostScript
// printing.
//virtual void SetPrintMode(int WXUNUSED(mode)) { }
//int GetPrintMode() const { return wxPRINT_POSTSCRIPT; }
// Return the layout direction for the current locale or wxLayout_Default
// if it's unknown
virtual wxLayoutDirection GetLayoutDirection() const;
// Change the theme used by the application, return true on success.
virtual bool SetNativeTheme(const wxString& theme) { return false; }
// command line parsing (GUI-specific)
// ------------------------------------------------------------------------
// virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
// virtual void OnInitCmdLine(wxCmdLineParser& parser);
// miscellaneous other stuff
// ------------------------------------------------------------------------
// called by toolkit-specific code to set the app status: active (we have
// focus) or not and also the last window which had focus before we were
// deactivated
virtual void SetActive(bool isActive, wxWindow *lastFocus);
};
// Force an exit from main loop
void wxExit();
// Yield to other apps/messages
bool wxYield();
// Yield to other apps/messages
void wxWakeUpIdle();
#endif // _WX_APP_H_BASE_
| true |
dd6b6a092b50623fc58d9236bd4f7d27df8a4bf0 | C++ | kartashowRoman/C-C-Qt-course | /HOMEWORK14/tictactoe.cpp | UTF-8 | 6,995 | 3.484375 | 3 | [] | no_license | #include <iostream>
#include <string>
#include <cstdlib>
#define PLAYER2 2
class Board {
public:
Board():board {" -"," -"," -"," -"," -"," -"," -"," -"," -",}{}
~Board(){}
std::string board[9];
};
//отображение игрового поля
class Display : public Board {
public:
Display(): mode(0){}
int ChooseGameMode(){
std::cout<<"Режим игры: \n1.С компьютером\n2.С игроком\n";
std::cin>>this->mode;
return this->mode;
}
int DrawBoard();
~Display(){}
int mode;
};
//
Display board;
//результат игры
class Result{
public:
Result(){}
int Tie();
int Win(std::string slot);
~Result(){}
};
Result result;
//игрок1
class PlayerX {
public:
PlayerX():move(" X"),move_count_x(0){}
int Check(int line, int column);
int Move(){
std::cout<<"\nХодит игрок 1\n";
int line = 0;
int column = 0;
std::cout<<"Номер строки \n";
std::cin>>line;
std::cout<<"Номер столбца \n";
std::cin>>column;
switch (line){
case 1:
Check(line,column);
board.board[column-1] = move;
break;
case 2:
Check(line,column);
board.board[2+column] = move;
break;
case 3:
Check(line,column);
board.board[5+column] = move;
break;
}
move_count_x++;
result.Tie();
result.Win(move);
return board.DrawBoard();
}
~PlayerX(){}
std::string move;
int move_count_x;
};
//игрок2
class PlayerO{
public:
PlayerO():move(" O"), move_count_o(0){}
int Check(int line, int column);
int Move(){
std::cout<<"\nХодит игрок 2\n";
int line = 0;
int column = 0;
std::cout<<"Номер строки \n";
std::cin>>line;
std::cout<<"Номер столбца \n";
std::cin>>column;
switch (line){
case 1:
Check(line,column);
board.board[column-1] = move;
break;
case 2:
Check(line,column);
board.board[2+column] = move;
break;
case 3:
Check(line,column);
board.board[5+column] = move;
break;
}
move_count_o++;
result.Win(move);
return board.DrawBoard();
}
~PlayerO(){}
std::string move;
int move_count_o;
};
int Again();
class Computer{
public:
Computer():move_count_o(0){}
int Move(){
std::cout<<"\nХодит АльфаСтар\n";
int slot = rand() % 9;
if(board.board[slot] == " -")
{
board.board[slot] = " O";
} else
return Again();
move_count_o++;
return board.DrawBoard();
}
~Computer(){}
int move_count_o;
};
PlayerX Player1;
PlayerO Player2;
Computer computer;
// возвращение для компьютера
int Again(){
srand (1);
return computer.Move();
}
//Прорисовка игрового поля
int Display::DrawBoard(){
std::cout<<"\nИГРА КРЕСТИКИ-НОЛИКИ\n\n\n";
std::cout<<' ';
for(int i = 0; i < 3; i++)
std::cout<<" "<<i+1;
std::cout<<std::endl;
std::cout<<1;
for(int i = 0; i < 3; i++)
{
std::cout<<board[i];
}
std::cout<<std::endl;
std::cout<<2;
for(int i = 3; i < 6; i++)
std::cout<<board[i];
std::cout<<std::endl;
std::cout<<3;
for(int i = 6; i < 9; i++)
std::cout<<board[i];
std::cout<<std::endl;
switch(mode){
case 2:
if(Player1.move_count_x <= Player2.move_count_o)
return Player1.Move();
else
return Player2.Move();
break;
case 1:
if(Player1.move_count_x <= computer.move_count_o)
return Player1.Move();
else
return computer.Move();
break;
}
}
//Проверка для игрока 1
int PlayerX::Check(int line, int column){
switch (line){
case 1:
if(board.board[column-1] == " X" || board.board[column-1] == " O")
return Player1.Move();
break;
case 2:
if(board.board[2+column] == " X" || board.board[2+column] == " O")
return Player1.Move();
break;
case 3:
if(board.board[5+column] == " X" || board.board[5+column] == " O")
return Player1.Move();
break;
}
}
//Проверка для игрока 2
int PlayerO::Check(int line, int column){
switch (line){
case 1:
if( board.board[column-1] == " X"|| board.board[column-1] == " O")
return Player2.Move();
break;
case 2:
if( board.board[2+column] == " X"|| board.board[2+column] == " O")
return Player2.Move();
break;
case 3:
if(board.board[5+column] == " X"|| board.board[5+column] == " O")
return Player2.Move();
break;
}
}
// обнуление поля
int Null(){
for(int i = 0; i < 9; i++)
board.board[i]=" -";
Player1.move_count_x = 0;
Player2.move_count_o = 0;
computer.move_count_o = 0;
return board.ChooseGameMode();
}
//////////// проверка на ничью
int Result::Tie(){
if(Player1.move_count_x == 5)
{
std::cout<<"////////////Ничья////////////\n";
for(int i = 0; i < 9; i++)
board.board[i]=" -";
Player1.move_count_x = 0;
Player2.move_count_o = 0;
computer.move_count_o = 0;
return board.ChooseGameMode();
}
}
// неукляюжая проверка на победу
int Result::Win(std::string slot){
int x = 0;
for(int i = 0; i < 9; i+=4)
{
if(board.board[i] == slot)
{
x++;
}
}
if(x == 3)
{
std::cout<<"////////////Победил"<<slot<<"////////////\n";
return Null();
}
x = 0;
for(int i = 2; i < 7; i+=2)
{
if(board.board[i] == slot)
{
x++;
}
}
if(x == 3)
{
std::cout<<"////////////Победил"<<slot<<"////////////\n";
return Null();
}
x = 0;
for(int i = 0; i < 3; i++)
{
if(board.board[i] == slot)
{
x++;
}
}
if(x == 3)
{
std::cout<<"////////////Победил"<<slot<<"////////////\n";
return Null();
}
x = 0;
for(int i = 3; i < 6; i++)
{
if(board.board[i] == slot)
{
x++;
}
}
if(x == 3)
{
std::cout<<"////////////Победил"<<slot<<"////////////\n";
return Null();
}
x = 0;
for(int i = 6; i < 9; i++)
{
if(board.board[i] == slot)
{
x++;
}
}
if(x == 3)
{
std::cout<<"////////////Победил"<<slot<<"////////////\n";
return Null();
}
x = 0;
for(int i = 0; i < 7; i+=3)
{
if(board.board[i] == slot)
{
x++;
}
}
if(x == 3)
{
std::cout<<"////////////Победил"<<slot<<"////////////\n";
return Null();
}
x = 0;
for(int i = 1; i < 8; i+=3)
{
if(board.board[i] == slot)
{
x++;
}
}
if(x == 3)
{
std::cout<<"////////////Победил"<<slot<<"////////////\n";
return Null();
}
x = 0;
for(int i = 2; i < 9; i+=3)
{
if(board.board[i] == slot)
{
x++;
}
}
if(x == 3)
{
std::cout<<"////////////Победил"<<slot<<"////////////\n";
return Null();
}
x = 0;
}
int main()
{
srand( time(NULL) );
board.ChooseGameMode();
board.DrawBoard();
Player1.Move();
if(board.mode == PLAYER2)
{
Player2.Move();
} else {
return computer.Move();
}
return 0;
}
| true |
0ac7c44af1299e36b2d4330499203ded986cdb91 | C++ | psalire/Chat-Application | /src/class_user.cc | UTF-8 | 393 | 3.296875 | 3 | [] | no_license | #include "user.h"
void User::setName(const std::string user_name) {
/* Check if valid username */
if (!std::regex_match(user_name, std::regex("^[0-9a-z]+$", std::regex::icase))) {
std::cout << "Error: Invalid username \"" << user_name
<< "\". Username must consist only of [a-zA-z0-9]. Exiting.\n";
exit(-1);
}
name = user_name;
}
| true |
7df6abf186ce1bc0436db455f1a7d4756553133e | C++ | Shaurov05/OJ-problem-solving | /oddsum.cpp | UTF-8 | 382 | 2.609375 | 3 | [] | no_license | #include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d", &t);
for(int i= 0 ;i<t ;i++){
int a,b, sum=0;
scanf("%d%d", &a,&b);
while(a<=b){
if(a%2!=0){
sum+= a;
}
a++;
}
printf("Case %d: %d\n", i+1 ,sum);
}
return 0;
}
| true |
b7a3a4608272eb84f2ad3186ea04518aa13689fe | C++ | Argonnite/metagraph | /lib/Association.h | UTF-8 | 4,417 | 2.8125 | 3 | [] | no_license | #include "AssociationList.h"
#ifndef _Association_h
#define _Association_h 1
#ifdef __GNUG__
#pragma interface
#endif
/*******************************************************************
Copyright (c) 1997
Hewlett-Packard Company
Permission to use, copy, modify, distribute and sell this software and
its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation. Hewlett-Packard Company makes no
representations about the suitability of this software for any
purpose. It is provided "as is" without express or implied warranty.
Programmer : Geroncio Galicia
Date of Creation : 7/11/97
********************************************************************/
#include <iostream.h>
#include "type.h"
class AssociatedObj;
class AssociationList;
/** A base class for objects that link to each other only once.
An Association object links to at most one other object of its type.
It is typically part of a AssociationList or is a member of a class
derived from AssociatedObj. An Association object can be linked to
another only once. Attempting to reseat an existing link without
first dissociating will return a message indicating failure. This
class behaves differently from an AssociatedObj in that it support
only one-to-one links and destruction or dissociating of an instance
will affect its partner instance. */
class Association {
public:
/**@name Owner identification methods */
//@{
/// Return my owner.
AssociatedObj& nearOwner();
/** Return the owner of my partner Association.
Returns NULL if there is no partner Association. */
AssociatedObj* farOwnerPtr();
//@}
/**@name Link-to-member methods
*Linking instantiates a bi-directional association. Linking to a
*far object is always accompanied by an implicit link back from
*the linked-to object. */
//@{
/** Link to a {\bf public} AssociationList member of an AssociatedObj.
Creates and returns the Association in the farList. Such a member
will be of subtype ListAssociation. Useful if a characteristic,
qualification, or attribute is attached to a particular list. */
Association& associate(AssociationList& farList);
/** Link to a {\bf public} Association member of an AssociatedObj.
Such a member will be of subtype MemberAssociation. Useful if a
characteristic, qualification, or attribute is attached to a
particular existing link. */
Association& associate(Association& farAssociation);
//@}
protected:
/// The Association to which I am linked (there can be only one).
Association *far;
// The local AssociatedObj owning {\bf *this}.
AssociatedObj &nearObj;
/** Constructor creates and inserts myself into a list.
Associations must be owned by an object and a list. Instantiating
{\bf *this} automatically updates the state of the owner list.
Note that this constructor is not public to prevent instantiation
by declaration. If instantiation by declaration is possible, then
it is also possible that the Destructor will be called twice: the
far Association is destroyed, thus destroying {\bf *this}, then
the end of the scope in which {\bf *this} resides is reached.
Instantiation by declaration should be possible only in derived
classes that avoid this scenario. */
Association(AssociatedObj& localObj);
/** Destructor deletes myself and partner.
Invokes dissociate(). */
virtual ~Association();
/** Delete my Associate and me.
My partner Associate is destroyed (if it is part of an
AssociationList) or reset (if it is an AssociatedObj subclass
public member). (The latter cannot happen with the base class
AssociatedObj but rather in classes derived from AssociatedObj
this method must be overridden to NULL its Association member's
pointer instead of deleting that member.) In short, if a derived
class is instantiated by declaration (see comments for the
Constructor above) then this method must be overridden. */
virtual void dissociate();
private:
/// Used to avoid infinite recursion during associating.
int isPaired;
/// Used to avoid calling destructor twice during "delete this".
int isDissociating;
};
#endif
| true |
4b7bf0fe57a110d71ea103dbb7603116750f682d | C++ | jlgallego99/DesarrolloSoftware_DS | /Practica1/S2/src/componenteEquipo.cc | UTF-8 | 228 | 2.5625 | 3 | [] | no_license | #include "componenteEquipo.h"
componenteEquipo::componenteEquipo(int c, string n){
coste = c;
nombre = n;
}
int componenteEquipo::getCoste(){
return coste;
}
string componenteEquipo::getNombre(){
return nombre;
}
| true |
cd3da5a1399f5528fe2f41c1123075905560c2d7 | C++ | beneG/il2_test | /cockroach_simulator/Cockroach.h | UTF-8 | 6,638 | 2.796875 | 3 | [] | no_license | #pragma once
#include <Windows.h>
#include <cmath>
#include <complex>
#include <list>
#include <memory>
#include <string>
#include "Food.h"
#include "static_global_vars.h"
class Cockroach
{
public:
constexpr static const int DEFAULT_RADIUS = 10;
constexpr static const int MAX_RADIUS = 20;
constexpr static const int SIGHT_RADIUS = DEFAULT_RADIUS * 10;
constexpr static const double DEFAULT_VELOCITY = 4.0;
enum class Status
{
NORMAL,
FRIGHTENED,
CONSUMING,
FULL,
EXPIRED
};
Cockroach(int x, int y) : m_x(x), m_y(y)
{
m_radius = DEFAULT_RADIUS;
m_velocity = DEFAULT_VELOCITY;
m_status = Status::NORMAL;
m_spawn_time = std::chrono::system_clock::now();
}
~Cockroach()
{
}
void draw(HDC hdc)
{
std::wstring status;
switch (m_status)
{
case Cockroach::Status::NORMAL:
status = L"searching";
break;
case Cockroach::Status::FRIGHTENED:
status = L"scared";
break;
case Cockroach::Status::CONSUMING:
status = L"eating";
break;
case Cockroach::Status::FULL:
status = L"full";
break;
case Cockroach::Status::EXPIRED:
status = L"returning";
break;
}
TextOut(hdc, (int)(m_x + m_radius), (int)(m_y - m_radius), status.c_str(), (int)status.length());
Ellipse(hdc, (int)(m_x - m_radius), (int)(m_y - m_radius), (int)(m_x + m_radius), (int)(m_y + m_radius));
}
void relative_rotate(double angle)
{
m_direction = m_direction * std::polar(1.0, angle);
}
void rotate(std::complex<double> direction)
{
m_direction = direction;
}
void fright(RECT *rect, double x, double y)
{
if (distance(x, y) < SIGHT_RADIUS * 3)
{
double alpha = atan2((m_y - y), (x - m_x));
m_direction = {sin(alpha - M_PI / 2), cos(alpha - M_PI / 2)};
m_status = Status::FRIGHTENED;
m_fright_time = std::chrono::system_clock::now();
}
}
void move(RECT *rect, std::list<std::shared_ptr<Cockroach>> &cockroaches, std::shared_ptr<Cockroach> self,
std::list<std::shared_ptr<Food>> &food_drops)
{
double sign = rng() % 2 == 0 ? -1.0 : 1.0;
if (m_x - m_radius < rect->left && m_y - m_radius < rect->top)
{
m_direction = {sin(M_PI / 4), cos(M_PI / 4)};
}
else if (m_x + m_radius > rect->right && m_y - m_radius < rect->top)
{
m_direction = {sin(-M_PI / 4), cos(-M_PI / 4)};
}
else if (m_x + m_radius > rect->right && m_y + m_radius > rect->bottom)
{
m_direction = {sin(-M_PI * 3 / 4), cos(-M_PI * 3 / 4)};
}
else if (m_x - m_radius < rect->left && m_y + m_radius > rect->bottom)
{
m_direction = {sin(M_PI * 3 / 4), cos(M_PI * 3 / 4)};
}
else if (m_x - m_radius < rect->left)
{
m_direction = {sin(M_PI / 2), cos(M_PI / 2)};
relative_rotate(sign * (rng() % 120 * M_PI / 180));
}
else if (m_y - m_radius < rect->top)
{
m_direction = {sin(0), cos(0)};
relative_rotate(sign * (rng() % 120 * M_PI / 180));
}
else if (m_x + m_radius > rect->right)
{
m_direction = {sin(-M_PI / 2), cos(-M_PI / 2)};
relative_rotate(sign * (rng() % 120 * M_PI / 180));
}
else if (m_y + m_radius > rect->bottom)
{
m_direction = {sin(-M_PI), cos(-M_PI)};
relative_rotate(sign * (rng() % 120 * M_PI / 180));
}
else
{
bool was_collision = false;
for (auto cockroach : cockroaches)
{
if (cockroach == self)
{ // it's me
continue;
}
if (cockroach->distance(m_x, m_y) < cockroach->get_radius() + m_radius)
{
double alpha = atan2(m_y - cockroach->get_y(), cockroach->get_x() - m_x);
m_direction = {sin(alpha - M_PI / 2), cos(alpha - M_PI / 2)};
cockroach->rotate(-1.0 * m_direction);
was_collision = true;
}
}
if (!was_collision && (m_status == Status::NORMAL || m_status == Status::CONSUMING))
{
bool food_found = false;
for (auto food : food_drops)
{
if (distance(food->get_x(), food->get_y()) < SIGHT_RADIUS)
{
food_found = true;
double alpha = atan2(food->get_y() - m_y, m_x - food->get_x());
m_direction = {sin(alpha - M_PI / 2), cos(alpha - M_PI / 2)};
if (distance(food->get_x(), food->get_y()) < m_radius + food->get_size())
{
m_status = Status::CONSUMING;
food->eat();
m_radius += Food::PIECE_SIZE;
if (m_radius >= MAX_RADIUS)
{
m_status = Status::FULL;
}
}
break;
}
}
if (!food_found)
{
m_status = Status::NORMAL;
relative_rotate(sign * (rng() % 20 * M_PI / 180));
}
}
if (!was_collision && (m_status == Status::FULL || m_status == Status::EXPIRED))
{
int nearest_corner_x = m_x < rect->right / 2 ? rect->left : rect->right;
int nearest_corner_y = m_y < rect->bottom / 2 ? rect->top : rect->bottom;
double alpha = atan2(nearest_corner_y - m_y, m_x - nearest_corner_x);
m_direction = {sin(alpha - M_PI / 2), cos(alpha - M_PI / 2)};
}
}
double velocity = (m_status == Status::FRIGHTENED ? 2.0 : 1.0) * m_velocity;
m_x += velocity * m_direction.real();
m_y += velocity * m_direction.imag();
if (m_status == Status::FRIGHTENED)
{
auto elapsed_seconds =
std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - m_fright_time)
.count();
if (elapsed_seconds > 4)
{
if (m_radius > MAX_RADIUS)
{
m_status = Status::FULL;
}
else
{
m_status = Status::NORMAL;
}
}
}
if (m_status == Status::NORMAL)
{
auto elapsed_seconds =
std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - m_spawn_time)
.count();
if (elapsed_seconds > 30)
{
m_status = Status::EXPIRED;
}
}
}
inline double distance(double x, double y)
{
return sqrt((m_x - x) * (m_x - x) + (m_y - y) * (m_y - y));
}
inline double get_radius()
{
return m_radius;
}
inline double get_x()
{
return m_x;
}
inline double get_y()
{
return m_y;
}
inline Status get_status()
{
return m_status;
}
private:
std::complex<double> m_direction;
double m_velocity;
double m_radius;
double m_x;
double m_y;
Status m_status;
std::chrono::time_point<std::chrono::system_clock> m_spawn_time;
std::chrono::time_point<std::chrono::system_clock> m_fright_time;
};
class CockroachFactory
{
public:
static std::shared_ptr<Cockroach> make_cockroach(int x, int y)
{
return std::make_shared<Cockroach>(x, y);
}
};
| true |
dd3b80fd19338e4bf1fc9ac717de6a451754466e | C++ | moonnesa/FYS3150-2020 | /Project3/solar_system_main.cpp | UTF-8 | 3,788 | 2.6875 | 3 | [] | no_license | #include "iostream"
#include "solvers.h"
#include <tuple>
using namespace std;
int main(int argc, char *argv[]){
double t = 10.0;
int n = 1000;
int N = n * int(t);
double h = 1. / double(n);
wanderer Earth(vec3(1,0,0), vec3(0,5,0), 0.0000003, "Earth");
/*wanderer Mercury(vec3( 3.495536068460927E-01,-1.244005354235778E-01,-4.322650728859492E-02), vec3( 4.227635822741497E-03, 2.766717966358528E-02, 1.872995651741010E-03)*365, 0.000000165, "Mercury");
wanderer Venus(vec3(-2.014564693577006E-01, 6.979647054471583E-01, 2.085192527188221E-02), vec3(-1.954030489393017E-02, -5.617030971633074E-03, 1.050380933499449E-03)*365, 0.00000245, "Venus");
wanderer Earth(vec3(9.197072435481757E-01, 3.769489356926712E-01, 6.612226445473284E-05), vec3(-6.680014422118789E-03, 1.591045745844236E-02, -4.285733910918290E-07)*365, 0.000003, "Earth");
wanderer Mars(vec3(1.313182054438775E+00, 5.238027403010505E-01, -2.143298790828418E-02), vec3(-4.580673738523137E-03, 1.421746938727736E-02, 4.104620361665089E-04)*365, 0.00000033, "Mars");
wanderer Jupiter(vec3(2.550209154629485E+00, -4.432721232593654E+00, -3.866707508925721E-02), vec3(6.447098824156304E-03, 4.121019457101368E-03, -1.613529989591600E-04)*365, 0.0001, "Jupiter");
wanderer Saturn(vec3(5.139559304458874E+00, -8.566560707385138E+00, -5.566040857035146E-02), vec3(4.473071224059222E-03, 2.856412892846955E-03,-2.280945466479504E-04)*365, 0.0000275, "Saturn");
wanderer Uranus(vec3(1.553730695000689E+01, 1.224236505232422E+01, -1.558191030077437E-01), vec3(-2.462967281250927E-03, 2.906026427771245E-03, 4.254080066644400E-05)*365, 0.000044, "Uranus");
wanderer Neptune(vec3(2.941173255905554E+01, -5.468183359613734E+00,-5.652169944272230E-01), vec3(5.527763030717538E-04, 3.104458967851615E-03, -7.691920531641856E-05)*365, 0.0000515, "Neptune");
wanderer Pluto(vec3(1.382472690342292E+01, -3.119979414554036E+01, -6.603664824603037E-01), vec3(2.943045461378601E-03, 5.994517978475793E-04, -9.154543587554921E-04)*365, 0.00000000655, "Pluto");
wanderer Sun(vec3(0,0,0), vec3(0,0,0), 1, "Sun");
solvers solverJS;
solvers solverMeS;
solvers solverES;
//solvers solverEJ;
solvers solverSS;
solvers solverNS;
solvers solverMaS;
solvers solverVS;
solvers solverUS;
solvers solverPS;
solverES.verlet(Earth, Sun, N, h, "Verlet_array_ES.txt");
//Earth.resetWanderer();
solverJS.verlet(Jupiter, Sun, N, h, "Verlet_array_JS.txt");
//Jupiter.resetForces();
solverMeS.verlet(Mercury, Sun, N, h, "Verlet_array_MeS.txt");
//solverES.euler(Earth, Sun, N, h, "Euler_array_ES.txt");
//Earth.resetWanderer();
solverMaS.verlet(Mars, Sun, N, h, "Verlet_array_MaS.txt");
solverNS.verlet(Neptune, Sun, N, h, "Verlet_array_NS.txt");
solverSS.verlet(Saturn, Sun, N, h, "Verlet_array_SS.txt");
solverSS.verlet(Pluto, Sun, N, h, "Verlet_array_PS.txt");
solverSS.verlet(Venus, Sun, N, h, "Verlet_array_VS.txt");
solverSS.verlet(Uranus, Sun, N, h, "Verlet_array_US.txt");
*/ //wanderer Earth(vec3(9.197072435481757E-01, 3.769489356926712E-01, 6.612226445473284E-05), vec3(-6.680014422118789E-03, 1.591045745844236E-02, -4.285733910918290E-07)*365, 0.000003, "Earth");
//wanderer Jupiter(vec3(2.550209154629485E+00, -4.432721232593654E+00, -3.866707508925721E-02), vec3(6.447098824156304E-03, 4.121019457101368E-03, -1.613529989591600E-04)*365, 1, "Jupiter");
wanderer Sun(vec3(0,0,0), vec3(0,0,0), 1, "Sun");
//solvers solveES;
//solveES.TBverlet(Earth, Sun, Jupiter, N, h, "EJS_array_ES.txt");
//Earth.resetWanderer();Jupiter.resetWanderer();
solvers solveJS;
solveJS.verlet(Earth, Sun, N, h, "JS_array.txt");
//solveJS.euler(Earth,Sun,N,h,"Euler_array.txt");
}
| true |
edc10dedc1006963928187e2b75d66adb72a2dcd | C++ | AlexOpanasevych/lab_2_sem | /unit6/5.cpp | UTF-8 | 278 | 2.984375 | 3 | [] | no_license | #include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
long mystrtol(char *p, char **end){
return strtol(p, end, 10);
}
int main() {
char * p = new char[10];
char *end;
cin.getline(p, 10);
cout << mystrtol(p, &end);
return 0;
} | true |
b557da6fb2ec4e401c0911b08d12539a900e325a | C++ | timzheng0804/Leetcode | /Inorder Successor in BST.cc | UTF-8 | 701 | 3.28125 | 3 | [] | no_license | /**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
void findSuccessor(TreeNode* root, int val, TreeNode* &next) {
if (!root) return;
findSuccessor(root->left, val, next);
if (next) return;
if (root->val > val) {
next = root;
return;
}
findSuccessor(root->right, val, next);
}
TreeNode* inorderSuccessor(TreeNode* root, TreeNode* p) {
TreeNode* next = NULL;
findSuccessor(root, p->val, next);
return next;
}
}; | true |
673b67eb4ab300a82ca56055bdc3f19517854b64 | C++ | IsRatJahan17/vs-code-c- | /vsCode c++/A_Very_Big_Sum.cpp | UTF-8 | 340 | 2.75 | 3 | [] | no_license | #include<bits/stdc++.h>
using namespace std;
int main(){
int n,pos=0,neg=0,zer=0;
cin>>n;
int* arr= new int[n];
while(n--){
cin>>arr[n-1];
}
for(int i=0;i<n;i++){
if(arr[i]>0) ++pos;
else if(arr[i]<0) neg++;
else zer++;
}
cout<<pos<<neg<<zer;
return 0;
}
| true |
62beb6d9cfb01fa06e9dab9011864c56111877f1 | C++ | open-goal/jak-project | /third-party/replxx/src/killring.hxx | UTF-8 | 1,651 | 2.984375 | 3 | [
"HPND-Markus-Kuhn",
"LicenseRef-scancode-unicode-mappings",
"BSD-3-Clause",
"GPL-1.0-or-later",
"ISC"
] | permissive | #ifndef REPLXX_KILLRING_HXX_INCLUDED
#define REPLXX_KILLRING_HXX_INCLUDED 1
#include <vector>
#include "unicodestring.hxx"
namespace replxx {
class KillRing {
static const int capacity = 10;
int size;
int index;
char indexToSlot[10];
std::vector<UnicodeString> theRing;
public:
enum action { actionOther, actionKill, actionYank };
action lastAction;
KillRing()
: size(0)
, index(0)
, lastAction(actionOther) {
theRing.reserve(capacity);
}
void kill(const char32_t* text, int textLen, bool forward) {
if (textLen == 0) {
return;
}
UnicodeString killedText(text, textLen);
if (lastAction == actionKill && size > 0) {
int slot = indexToSlot[0];
int currentLen = static_cast<int>(theRing[slot].length());
UnicodeString temp;
if ( forward ) {
temp.append( theRing[slot].get(), currentLen ).append( killedText.get(), textLen );
} else {
temp.append( killedText.get(), textLen ).append( theRing[slot].get(), currentLen );
}
theRing[slot] = temp;
} else {
if (size < capacity) {
if (size > 0) {
memmove(&indexToSlot[1], &indexToSlot[0], size);
}
indexToSlot[0] = size;
size++;
theRing.push_back(killedText);
} else {
int slot = indexToSlot[capacity - 1];
theRing[slot] = killedText;
memmove(&indexToSlot[1], &indexToSlot[0], capacity - 1);
indexToSlot[0] = slot;
}
index = 0;
}
}
UnicodeString* yank() { return (size > 0) ? &theRing[indexToSlot[index]] : 0; }
UnicodeString* yankPop() {
if (size == 0) {
return 0;
}
++index;
if (index == size) {
index = 0;
}
return &theRing[indexToSlot[index]];
}
};
}
#endif
| true |
9cc1f5a878e85a6cc8705d063e9f637d57e7f2ef | C++ | eitanshalev/Lion-King-Scar | /Lion King Scar/include/GameObject.h | UTF-8 | 1,022 | 2.890625 | 3 | [] | no_license | #pragma once
#include "Globals.h"
class GameObject {
public:
virtual void draw(sf::RenderWindow&) = 0;
GameObject(sf::Vector2f& location) : m_location(location), m_startingLocation(location){}
virtual void animation(float deltaTime) = 0;
virtual void update(float deltatime) = 0;
virtual void move(float deltaTime) = 0;
virtual ~GameObject() = default;
sf::Vector2f& getLocation() { return m_location; }
void setLocation(const sf::Vector2f& location) { m_location = location; }
virtual bool checkCollision(const sf::FloatRect& floatRect) const = 0;
virtual sf::FloatRect getRect() const = 0;
bool exists() {return m_isExcist;}
void remove() { m_isExcist = false; }
void resetLocation() { m_location = m_startingLocation; }
void setStartingLocation(const sf::Vector2f& location) { m_startingLocation = location; }
sf::Vector2f& getStartingLocation() { return m_startingLocation; }
private:
sf::Vector2f m_location;
sf::Vector2f m_startingLocation;
bool m_isExcist = true;
}; | true |
f53f569fc3509c999058716e28f4a4e1a45d953d | C++ | dbuksbaum/FreeOrion | /FreeOrion/util/XMLObjectFactory.h | UTF-8 | 4,075 | 3.109375 | 3 | [] | no_license | // -*- C++ -*-
/* Copyright (C) 2006 T. Zachary Laine
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1
of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA
If you do not wish to comply with the terms of the LGPL please
contact the author as other terms are available for a fee.
Zach Laine
whatwasthataddress@hotmail.com */
/** \file XMLObjectFactory.h
Contains the XMLObjectFactory class template, which allows the user to register object-creation functions and then
automatically create objects from XML encodings. */
#ifndef _XMLObjectFactory_h_
#define _XMLObjectFactory_h_
#include "XMLDoc.h"
#include <map>
#include <string>
#include <stdexcept>
/** Thrown when a generated object is requested with an unknown tag. */
class NoSuchGenerator : public GG::ExceptionBase
{
public:
NoSuchGenerator () throw() : ExceptionBase() {}
NoSuchGenerator (const std::string& msg) throw() : ExceptionBase(msg) {}
virtual const char* type() const throw()
{return "NoSuchGenerator";}
};
/** This class creates polymorphic subclasses of base class T from XML-formatted text. For any polymorphic class hierarchy,
you can instantiate XMLObjectFactory with the type of the hierarchy's base class, and provide functions that can each
construct one specific class in the hierarchy. By providing a string that identifies each class, and creating XML objects
with that string as a tag, you can ensure a method for creating the correct polymorphic subclass object at run-time. */
template <class T>
class XMLObjectFactory
{
public:
typedef T* (*Generator)(const XMLElement&); ///< this defines the function signature for XMLObjectFactory object generators
/** \name Structors */ //@{
XMLObjectFactory(); ///< ctor
//@}
/** \name Accessors */ //@{
/** returns a heap-allocated subclass object of the appropriate type \throw NoSuchGenerator Throws if \a elem
has an unknown tag. */
T* GenerateObject(const XMLElement& elem) const;
//@}
/** \name Mutators */ //@{
/** adds a new generator (or replaces one that already exists) that can generate subclass objects described by \a
name */
void AddGenerator(const std::string& name, Generator gen);
/** removes the generator that can generate subclass objects described by \a name, if one exists */
void RemoveGenerator(const std::string& name);
//@}
private:
typedef typename std::map<std::string, Generator> GeneratorMap;
/** mapping from strings to functions that can create the type of object that corresponds to the string */
GeneratorMap m_generators;
};
// template implementations
template <class T>
XMLObjectFactory<T>::XMLObjectFactory()
{
}
template <class T>
T* XMLObjectFactory<T>::GenerateObject(const XMLElement& elem) const ///< returns a heap-allocated subclass object of the appropriate type
{
typename GeneratorMap::const_iterator it = m_generators.find(elem.Tag());
if (it == m_generators.end())
throw NoSuchGenerator("XMLObjectFactory::GenerateObject(): No generator exists for XMLElements with the tag \"" + elem.Tag() + "\".");
return it->second(elem);
}
template <class T>
void XMLObjectFactory<T>::AddGenerator(const std::string& name, Generator gen)
{
m_generators[name] = gen;
}
template <class T>
void XMLObjectFactory<T>::RemoveGenerator(const std::string& name)
{
m_generators.erase(name);
}
#endif // _XMLObjectFactory_h_
| true |
d861f93030dca839b235e7cae0388c492e37bf86 | C++ | r4hu1s0n7/HarryPotter-Spells | /Diffindo.cpp | UTF-8 | 1,915 | 2.9375 | 3 | [] | no_license | #include <iostream>
#include <filesystem>
#include <queue>
#include <algorithm>
#include <fstream>
#include "cxxopts.hpp"
using namespace std;
using namespace cxxopts;
namespace fs = std::filesystem;
void parse(int argc, char* argv[], char& delimiter, int& field, vector<fs::path>& inputs) {
try {
cxxopts::Options options(argv[0], "CUT Program Demo");
options.allow_unrecognised_options()
.add_options()
("d,delimiter", "use DELIM instead of TAB for field delimiter", value<char>()->default_value("\t"), "\\t")
("f,field", "Select Only This Field", value<int>()->default_value("0"), "0")
("FILE", "Name Of The File To Read From", value<vector<string>>());
("h,help", "Print Help");
options.parse_positional({ "FILE" });
auto result = options.parse(argc, argv);
if (result.count("help")) {
cout << options.help({ "" });
exit(0);
}
if (result.count("delimiter")) {
delimiter = result["delimiter"].as<char>();
}
if (result.count("field")) {
field = result["field"].as<int>();
}
if (result.count("FILE")) {
const auto& names = result["FILE"].as<vector<string>>();
for (const auto& name : names) {
inputs.emplace_back(name);
}
}
}
catch (cxxopts::OptionException & e) {
cerr << "Exception Occured In Parsing Arguments \n" << e.what() << endl;
exit(-1);
}
}
// 5
int main6(int argc, char* argv[]) {
vector<fs::path> inputs;
char delimiter;
int field;
parse(argc, argv, delimiter, field, inputs);
for (const auto& input : inputs) {
if (!fs::exists(input))
continue;
ifstream ifs(input.c_str());
cout << input.filename().string() << " : " << endl;
string str;
int count = 0;
while (true) {
count++;
getline(ifs, str, delimiter);
if (count == field)
cout << str << endl;
if (ifs.eof() || ifs.fail())
break;
}
}
return 0;
} | true |
1eb4d9792d4d71f4d38b66172bc4ea40710977cf | C++ | rsguru/cs124 | /homework/example26EoF.cpp | UTF-8 | 430 | 2.9375 | 3 | [] | no_license | #include <iostream>
#include <fstream>
main usingEoF(const char filename[])
{
ifstream fin(filename);
if (fin.fail())
{
cout << "Unable to open file " << filename endl;
return;
}
// get the data and display it on the screen
char test[256];
// keep reading as long as not at the end of file
while (!fin.eof())
{
fin >. text;
cout << "'" << text << "' ";
}
fin.close();
}
| true |
11c8dcd1bf644143a14cfeddc247567539ccdef0 | C++ | daanvanhasselt/Triangle-Visuals | /TriangleReceiver v.0.9 copy/src/testApp.cpp | UTF-8 | 9,459 | 2.78125 | 3 | [] | no_license | #include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
maximumAreaThreshold = getMaximumTriangleArea()/5; // we'll use this value for determining which layers to enable
triangleReceiver.setup(3334); // setup trianglereceiver to listen on port 3334
ofEnableAlphaBlending();
ofEnableSmoothing();
// img player
shape1.loadSequence("image/shape_layer", "png", 1, 20, 2);
shape1.preloadAllFrames();
playingImg = false;
}
//--------------------------------------------------------------
void testApp::update(){
triangleReceiver.update(); // receive triangle data
triangleReceiver.pulse.update();
list<Triangle*>::iterator triangleIt;
for(triangleIt = triangleReceiver.triangles.begin(); triangleIt != triangleReceiver.triangles.end(); triangleIt++){ // set radius, center for every triangle
(*triangleIt)->radius = getMaximumRadiusInTriangle((*triangleIt)->A, (*triangleIt)->B, (*triangleIt)->C);
(*triangleIt)->center = getTriangleCenter((*triangleIt)->A, (*triangleIt)->B, (*triangleIt)->C);
(*triangleIt)->lengthOfAB = (ofDist((*triangleIt)->A.x, (*triangleIt)->A.y, (*triangleIt)->B.x, (*triangleIt)->B.y)); // set linelengths
(*triangleIt)->lengthOfBC = (ofDist((*triangleIt)->B.x, (*triangleIt)->B.y, (*triangleIt)->C.x, (*triangleIt)->C.y));
(*triangleIt)->lengthOfCA = (ofDist((*triangleIt)->C.x, (*triangleIt)->C.y, (*triangleIt)->A.x, (*triangleIt)->A.y));
(*triangleIt)->radius1 = (*triangleIt)->radius/5;
(*triangleIt)->radius2 = ((*triangleIt)->radius/5)*2;
(*triangleIt)->radius3 = ((*triangleIt)->radius/5)*3;
(*triangleIt)->radius4 = ((*triangleIt)->radius/5)*4;
(*triangleIt)->radius5 = (*triangleIt)->radius;
cout << "AB: " << (*triangleIt)->lengthOfAB << endl;
cout << "BC: " << (*triangleIt)->lengthOfBC << endl;
cout << "CA: " << (*triangleIt)->lengthOfCA << endl;
// enable or disable each of the 5 layers according to the area of the triangle
float triangleArea = getTriangleArea((*triangleIt)->A, (*triangleIt)->B, (*triangleIt)->C);
if(triangleArea < maximumAreaThreshold){
(*triangleIt)->state = TriangleStateDrawFirstLayer;
}
else if(triangleArea > maximumAreaThreshold && triangleArea < maximumAreaThreshold*2 ){
(*triangleIt)->state = TriangleStateDrawSecondLayer;
}
else if(triangleArea > maximumAreaThreshold*2 && triangleArea < maximumAreaThreshold*3){
(*triangleIt)->state = TriangleStateDrawThirdLayer;
}
else if(triangleArea > maximumAreaThreshold*3 && triangleArea < maximumAreaThreshold*4){
(*triangleIt)->state = TriangleStateDrawFourthLayer;
}
else{
(*triangleIt)->state = TriangleStateDrawFifthLayer;
}
}
}
//--------------------------------------------------------------
void testApp::draw(){
ofBackground(0, 0, 0);
triangleReceiver.pulse.draw();
list<Triangle*>::iterator triangleIt;
for(triangleIt = triangleReceiver.triangles.begin(); triangleIt != triangleReceiver.triangles.end(); triangleIt++){
// draw (red) filled triangle, opacity determined by tension
ofFill();
ofSetColor(255, 0, 0, (*triangleIt)->tension * 255.0f);
ofTriangle((*triangleIt)->A, (*triangleIt)->B, (*triangleIt)->C);
// draw (white) lines, full opacity
ofSetColor(255);
ofSetLineWidth(2);
ofLine((*triangleIt)->A.x,(*triangleIt)->A.y, (*triangleIt)->B.x,(*triangleIt)->B.y);
ofLine((*triangleIt)->B.x,(*triangleIt)->B.y,(*triangleIt)->C.x,(*triangleIt)->C.y);
ofLine((*triangleIt)->C.x,(*triangleIt)->C.y, (*triangleIt)->A.x,(*triangleIt)->A.y);
// draw (green) animation placeholders
//ofSetColor(0, 255, 0);
ofSetLineWidth(1);
ofNoFill();
if((*triangleIt)->state == TriangleStateDrawFirstLayer){
drawShapeWithRotation((*triangleIt)->center, 100, (*triangleIt)->radius1, 1);
//ofCircle((*triangleIt)->center, (*triangleIt)->radius/5);
}
else if((*triangleIt)->state == TriangleStateDrawSecondLayer){
// ofCircle((*triangleIt)->center, (*triangleIt)->radius/5);
// ofCircle((*triangleIt)->center, ((*triangleIt)->radius/5*2));
drawShapeWithRotation((*triangleIt)->center, 100, (*triangleIt)->radius1, 1);
drawShapeWithRotation((*triangleIt)->center, 100, (*triangleIt)->radius2, 5);
}
else if((*triangleIt)->state == TriangleStateDrawThirdLayer){
// ofCircle((*triangleIt)->center, (*triangleIt)->radius/5);
// ofCircle((*triangleIt)->center, ((*triangleIt)->radius/5*2));
// ofCircle((*triangleIt)->center, ((*triangleIt)->radius/5*3));
drawShapeWithRotation((*triangleIt)->center, 100, (*triangleIt)->radius1, 1);
drawShapeWithRotation((*triangleIt)->center, 100, (*triangleIt)->radius2, 5);
drawShapeWithRotation((*triangleIt)->center, 100, (*triangleIt)->radius3, 10);
}
else if((*triangleIt)->state == TriangleStateDrawFourthLayer){
// ofCircle((*triangleIt)->center, (*triangleIt)->radius/5);
// ofCircle((*triangleIt)->center, ((*triangleIt)->radius/5*2));
// ofCircle((*triangleIt)->center, ((*triangleIt)->radius/5*3));
// ofCircle((*triangleIt)->center, ((*triangleIt)->radius/5*4));
drawShapeWithRotation((*triangleIt)->center, 100, (*triangleIt)->radius1, 1);
drawShapeWithRotation((*triangleIt)->center, 100, (*triangleIt)->radius2, 5);
drawShapeWithRotation((*triangleIt)->center, 100, (*triangleIt)->radius3, 10);
drawShapeWithRotation((*triangleIt)->center, 100, (*triangleIt)->radius4, 13);
}
else if((*triangleIt)->state == TriangleStateDrawFifthLayer){
ofCircle((*triangleIt)->center, (*triangleIt)->radius/5);
// ofCircle((*triangleIt)->center, ((*triangleIt)->radius/5*2));
// ofCircle((*triangleIt)->center, ((*triangleIt)->radius/5*3));
// ofCircle((*triangleIt)->center, ((*triangleIt)->radius/5*4));
drawShapeWithRotation((*triangleIt)->center, 100, (*triangleIt)->radius1, 1);
drawShapeWithRotation((*triangleIt)->center, 100, (*triangleIt)->radius2, 5);
drawShapeWithRotation((*triangleIt)->center, 100, (*triangleIt)->radius3, 10);
drawShapeWithRotation((*triangleIt)->center, 100, (*triangleIt)->radius4, 13);
drawShapeWithRotation((*triangleIt)->center, 100, (*triangleIt)->radius5, 17);
}
}
// draw all persons
list<Person*>::iterator personIt;
for(personIt = triangleReceiver.persons.begin(); personIt != triangleReceiver.persons.end(); personIt++){
(*personIt)->draw();
}
}
//--------------------------------------------------------------
ofPoint testApp::getTriangleCenter(ofPoint A, ofPoint B, ofPoint C){
float lengthOfAB = (ofDist(A.x, A.y, B.x, B.y));
float lengthOfBC = (ofDist(B.x, B.y, C.x, C.y));
float lengthOfCA = (ofDist(C.x, C.y, A.x, A.y));
float perimeter = (lengthOfAB + lengthOfBC + lengthOfCA);
ofPoint triangleCenter = ofPoint(((lengthOfBC * A) + (lengthOfCA * B) + (lengthOfAB * C)) / perimeter);
return(triangleCenter);
}
//--------------------------------------------------------------
float testApp::getMaximumRadiusInTriangle(ofPoint A, ofPoint B, ofPoint C){
float lengthOfAB = (ofDist(A.x, A.y, B.x, B.y));
float lengthOfBC = (ofDist(B.x, B.y, C.x, C.y));
float lengthOfCA = (ofDist(C.x, C.y, A.x, A.y));
float perimeter = (lengthOfAB + lengthOfBC + lengthOfCA);
float semiPerimeter = perimeter/2;
float maxRadius = sqrtf( ( (semiPerimeter - lengthOfAB) * (semiPerimeter - lengthOfBC) * (semiPerimeter - lengthOfCA) ) / semiPerimeter);
return(maxRadius);
}
//--------------------------------------------------------------
float testApp::getTriangleArea(ofPoint A, ofPoint B, ofPoint C){
float lengthOfAB = (ofDist(A.x, A.y, B.x, B.y));
float lengthOfBC = (ofDist(B.x, B.y, C.x, C.y));
float lengthOfCA = (ofDist(C.x, C.y, A.x, A.y));
float perimeter = (lengthOfAB + lengthOfBC + lengthOfCA);
float semiPerimeter = perimeter/2;
float area = sqrtf( semiPerimeter * ( (semiPerimeter - lengthOfAB) * (semiPerimeter - lengthOfBC) * (semiPerimeter - lengthOfCA) ));
return(area);
}
//--------------------------------------------------------------
float testApp::getMaximumTriangleArea(){
float maxSideLength = 325;
float maxSemiPerimeter = (maxSideLength*3)/2;
float maxArea = sqrtf( maxSemiPerimeter * ( (maxSemiPerimeter - maxSideLength) * (maxSemiPerimeter - maxSideLength) * (maxSemiPerimeter - maxSideLength) ) );
float areaThreshold = maxArea/5;
return(areaThreshold);
}
//--------------------------------------------------------------
void testApp::drawShapeWithRotation(ofPoint centerPoint, int rotation, int radius, int layer){
ofPushMatrix();
ofTranslate(centerPoint.x, centerPoint.y, 0);
ofRotateZ(rotation);
shape1.getFrame(layer)->draw(0 -(radius)/2,0 - (radius)/2, radius*2, radius*2);
ofPopMatrix();
}
| true |
48d9e4e556fa8b1d06d05be985745761c8ceed5f | C++ | Neverous/codeforces | /188/a.cpp | UTF-8 | 218 | 2.59375 | 3 | [] | no_license | /* 2013
* Maciej Szeptuch
* II UWr
*/
#include <cstdio>
long long int n, p;
int main(void)
{
scanf("%I64d %I64d", &n, &p);
printf("%I64d\n", (p <= (n + 1) / 2) ? 2 * p - 1 : 2 * (p - (n + 1) / 2));
return 0;
}
| true |
72bd2c91bca53dced735ff099d18fad94a20b93b | C++ | dchao34/kde_cv | /data/weighted_down_sample.cc | UTF-8 | 1,394 | 3.140625 | 3 | [] | no_license | #include <iostream>
#include <string>
#include <fstream>
#include <algorithm>
#include <random>
#include "file_io_utils.h"
using namespace std;
// --------------------------------------------------------------------
// Input:
// File with one record per line, delimited with ",". One of the
// column entry specifies a record weight.
// Output:
// File with one record per line, delimited with ",". It is a
// subset of the input file, down sampled according to record
// weight.
// --------------------------------------------------------------------
int main(int argc, char *argv[]) {
if (argc != 3) {
cerr << "usage: ./weighted_down_sample original_fname down_sampled_fname" << endl;
return 1;
}
// open files for reading/writing
ifstream fin; ofstream fout;
open_for_reading(fin, argv[1]);
open_for_writing(fout, argv[2]);
// write title line
string line; getline(fin, line);
fout << line << "\n";
// down sample according to weight
random_device rd;
mt19937_64 e(rd());
uniform_real_distribution<> u(0, 1);
size_t line_cnt = 0;
vector<string> tokens;
while (getline(fin, line)) {
tokenize(line, tokens, ",");
if (u(e) <= stod(tokens[3])) {
fout << line << "\n";
}
++line_cnt;
}
// clean up
fin.close(); fout.close();
cout << "Read " << line_cnt << " lines." << endl;
return 0;
}
| true |
d1eec354c8fb8c9186589e5af29590d4f41eb59a | C++ | junxzm1990/ASAN-- | /testcases/juliet_test_suite/testcases/CWE134_Uncontrolled_Format_String/s04/CWE134_Uncontrolled_Format_String__wchar_t_console_snprintf_84.h | UTF-8 | 1,856 | 2.890625 | 3 | [] | no_license | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE134_Uncontrolled_Format_String__wchar_t_console_snprintf_84.h
Label Definition File: CWE134_Uncontrolled_Format_String.label.xml
Template File: sources-sinks-84.tmpl.h
*/
/*
* @description
* CWE: 134 Uncontrolled Format String
* BadSource: console Read input from the console
* GoodSource: Copy a fixed string into data
* Sinks: snprintf
* GoodSink: snwprintf with "%s" as the third argument and data as the fourth
* BadSink : snwprintf with data as the third argument
* Flow Variant: 84 Data flow: data passed to class constructor and destructor by declaring the class object on the heap and deleting it after use
*
* */
#include "std_testcase.h"
#ifndef _WIN32
#include <wchar.h>
#endif
namespace CWE134_Uncontrolled_Format_String__wchar_t_console_snprintf_84
{
#ifndef OMITBAD
class CWE134_Uncontrolled_Format_String__wchar_t_console_snprintf_84_bad
{
public:
CWE134_Uncontrolled_Format_String__wchar_t_console_snprintf_84_bad(wchar_t * dataCopy);
~CWE134_Uncontrolled_Format_String__wchar_t_console_snprintf_84_bad();
private:
wchar_t * data;
};
#endif /* OMITBAD */
#ifndef OMITGOOD
class CWE134_Uncontrolled_Format_String__wchar_t_console_snprintf_84_goodG2B
{
public:
CWE134_Uncontrolled_Format_String__wchar_t_console_snprintf_84_goodG2B(wchar_t * dataCopy);
~CWE134_Uncontrolled_Format_String__wchar_t_console_snprintf_84_goodG2B();
private:
wchar_t * data;
};
class CWE134_Uncontrolled_Format_String__wchar_t_console_snprintf_84_goodB2G
{
public:
CWE134_Uncontrolled_Format_String__wchar_t_console_snprintf_84_goodB2G(wchar_t * dataCopy);
~CWE134_Uncontrolled_Format_String__wchar_t_console_snprintf_84_goodB2G();
private:
wchar_t * data;
};
#endif /* OMITGOOD */
}
| true |
726936f12a35f2865d3c44233ce81270a8a470a2 | C++ | watercannons/UCSB-CS16-Projects-and-Homework | /CS 16 HW/p5/HW5PrintASCIIPart2UNFINISHED.cpp | UTF-8 | 2,797 | 2.6875 | 3 | [] | no_license | #include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main(int argc, char *argv[])
{
//argc is the number of words
//argv is a string of all the words, stored in array positions
bool ifOutputFile = false;
string fileName;
string outputFile;
if(argc < 2)
missing();
fileName = argv[1];
for(int i = 0; i < argc; i++)
{
if(argv[i][0] == '-') //detects output code
{
if(argv[i] == "-o")
{
if(i == argc - 1)
//proceed with output to file operations
outputFile = argv[i+1];
ifOutputFile = true;
}
else
{
//call badOption, exit
badOption("argv[i");
}
}
}
//
fstream indata;
fstream outputResults;
//char fileName[] = argv[0];
indata.open(fileName,ios::in);
if(indata.fail())
{
cerr << "error opening file";
exit(-1);
}
int countTotal = 0;
int charCount[128] = {};
char x = ' ';
char outdata = ' ';
for(int i = 0; i < 128; i++)
{
charCount[i] = 0;
}
while(indata.get(outdata))
{
countTotal++;
charCount[int(outdata)]++;
}
indata.close();
outputResults.open(outputFile,ios::out);
if(outputResults.fail())
{
//badFile(char[](outputFile));
}
prHeader(outputResults);
for(int i = 0; i < 33; i++)
{
if(charCount[i] != 0)
{
prCountStr(outputResults, i, symbols[i] ,charCount[i]);
}
}
for(int i = 33; i < 127; i++)
{
if(charCount[i] != 0)
{
x = i;
prCountChr(outputResults, i, x, charCount[i]);
}
}
if(charCount[127] != 0)
{
prCountStr(outputResults, 127, symbolDel, charCount[127]);
}
prTotal(outputResults,countTotal);
outputResults.close();
return 0;
}
//These are modifications from common.h, since this program requires printing out the results, rather than
void prHeaderOut() {
cout << "Code\tChar\tCount\n----\t----\t-----\n";
}
void prCountStrOut(int code, const char str[], int count) {
cout << std::setw(3) << code << '\t' << str << '\t'
<< std::setw(5) << count << std::endl;
}
void prCountChrOut(int code, const char chr, int count) {
cout << std::setw(3) << code << '\t' << chr << '\t'
<< std::setw(5) << count << std::endl;
}
void prTotalOut(int count) {
cout << "\t\t-----\nTotal\t\t"
<< std::setw(5) << count << std::endl;
} | true |
8c8538fd6e5670f01974829a81e765fedad4520d | C++ | Mohit-121/Arjuna_files | /Arjuna 20-9-19/selling_idols.cpp | UTF-8 | 1,393 | 3.453125 | 3 | [] | no_license | #include<bits/stdc++.h>
using namespace std;
int getAnswer(int* cost,int* sellingPrice,int numIdols,int levels,int initial){
if(numIdols==0){ //If we have no ideals left then return no of coins
return initial;
}
if(levels==0){
return INT_MIN; //If we have exhausted levels then retunr -infinity
}
int option1=INT_MIN,option2=INT_MIN; //Two options either to level up and sell or to sell the idols
if(initial>=cost[0]){
option1=getAnswer(cost,sellingPrice,numIdols-1,levels,initial+sellingPrice[0]-cost[0]);
}
option2=getAnswer(cost+1,sellingPrice+1,numIdols,levels-1,initial);
return max(option1,option2); //return maximum of both options
}
int main(){
int numIdols,levels,initial;
cin>>numIdols>>levels>>initial; //Taking in inputs
int* cost=new int[levels]();
cost[0]=0;
for(int i=1;i<levels;i++){
cin>>cost[i];
cost[i]+=cost[i-1]; //cost of next level will be cost of levels before that and this level
}
int* sellingPrice=new int[levels];
for(int i=0;i<levels;i++){
cin>>sellingPrice[i]; //Taking selling price as inputs
}
cout<<getAnswer(cost,sellingPrice,numIdols,levels,initial)<<endl; //Backtracking approach to get the solution
delete[] sellingPrice;
delete[] cost; //Deleting the arrays when job is done
} | true |
f6f080f0fef482e1facb766d872e537c78d762e2 | C++ | Mr-Poseidon/CFile | /C网/1163排队买票(递归).cpp | UTF-8 | 386 | 2.796875 | 3 | [] | no_license | #include<stdio.h>
int ans,na,ka;
void fun(int m,int n,int k)
{
if(ka>na)return;
if(m==0)
{
ans++;return;
}
for(int i=k;i>0;i--)
{
ka++;
fun(m-1,n,k-1);
ka--;
}
for(int i=n;i>0;i--)
{
na++;
fun(m-1,n-1,k);
na--;
}
return;
}
int main()
{
int m,n,k;
while(~scanf("%d%d%d",&m,&n,&k))
{
ans=0,na=0,ka=0;
fun(m,n,k);
printf("%d",ans);
}
return 0;
}
| true |
1a998ae8f4145134393188badc51d57c51a90598 | C++ | TomLeeLive/aras-p-dingus | /dingus/dingus/resource/StorageResourceBundle.h | UTF-8 | 4,202 | 2.734375 | 3 | [
"MIT"
] | permissive | // --------------------------------------------------------------------------
// Dingus project - a collection of subsystems for game/graphics applications
// --------------------------------------------------------------------------
#ifndef __STORAGE_RESOURCE_BUNDLE_H
#define __STORAGE_RESOURCE_BUNDLE_H
#include "ResourceBundle.h"
#include "ResourceId.h"
#include "../console/Console.h"
#include "../utils/Errors.h"
namespace dingus {
template<class T>
class CStorageResourceBundle : public IResourceBundle {
private:
typedef std::map<CResourceId, T*> TResourceMap;
public:
virtual ~CStorageResourceBundle() = 0 {}
/**
* Gets or loads resource given it's name.
* Name is without pre-path and without file extension.
*/
T* getResourceById( const CResourceId& id ) {
T* resource = trygetResourceById( id );
if( resource )
return resource;
// error
std::string msg = "Can't find resource '" + id.getUniqueName() + "'";
CConsole::CON_ERROR.write( msg );
THROW_ERROR( msg );
}
/**
* Gets or loads resource given it's name, doesn't throw.
* Name is without pre-path and without file extension.
*/
T* trygetResourceById( const CResourceId& id ) {
// find if already loaded
T* resource = findResource( id );
if( resource )
return resource;
// try load
resource = tryLoadResourceById( id );
if( resource ) {
mResourceMap.insert( std::make_pair( id, resource ) );
return resource;
}
return NULL;
}
// NOTE: deletes the resource, so make sure no one references it!
void clearResourceById( CResourceId const& id ) {
TResourceMap::iterator it = mResourceMap.find( id );
if( it != mResourceMap.end() ) {
assert( (*it).second );
// error
std::string msg = "Clearing resource '" + id.getUniqueName() + "'";
CONSOLE.write( msg );
deleteResource( *it->second );
mResourceMap.erase( it );
}
}
void clear() {
for( TResourceMap::iterator it = mResourceMap.begin(); it != mResourceMap.end(); ) {
assert( (*it).second );
deleteResource( *it->second );
it = mResourceMap.erase( it );
}
}
void addDirectory( const std::string& d ) { mDirectories.push_back(d); }
protected:
CStorageResourceBundle() { }
T* findResource( CResourceId const& id ) {
TResourceMap::const_iterator it = mResourceMap.find( id );
return ( ( it != mResourceMap.end() ) ? it->second : NULL );
}
/**
* Try to load resource. Default implementation tries
* all extensions. Simpler ones can just append pre-dir and extension
* to id and use loadResourceById(), or some other bundle to load.
*/
virtual T* tryLoadResourceById( const CResourceId& id ) {
size_t nd = mDirectories.size();
size_t ne = mExtensions.size();
// try all directories
for( size_t d = 0; d < nd; ++d ) {
// try all extensions
for( size_t e = 0; e < ne; ++e ) {
CResourceId fullid( mDirectories[d] + id.getUniqueName() + mExtensions[e] );
T* resource = loadResourceById( id, fullid );
if( resource )
return resource;
}
}
// If all that failed, maybe ID already contains full path and extension
// (maybe useful in tools). Try loading it.
return loadResourceById( id, id );
}
/**
* Performs actual loading of resource.
* On failure to find resource, should silently return NULL - storage
* bundle will attempt another extension. On other failure
* (eg. format mismatch) can assert/throw etc.
*
* @param id Resource ID.
* @param fullName Full path to resource (with pre-dir(s) and extension).
*/
virtual T* loadResourceById( const CResourceId& id, const CResourceId& fullName ) = 0;
virtual void deleteResource( T& resource ) = 0;
protected:
typedef std::vector<std::string> TStringVector;
void addExtension( const char* e ) { mExtensions.push_back(e); }
const TStringVector& getExtensions() const { return mExtensions; }
const TStringVector& getDirectories() const { return mDirectories; }
protected:
TResourceMap mResourceMap;
private:
TStringVector mDirectories;
TStringVector mExtensions;
};
}; // namespace
#endif
| true |
877ab93ecfa7711f78a1b9b898fe7ee50f62465b | C++ | DanielFHermanadez/Readme | /Trabajo#1/C++/Trabajo#5.cpp | UTF-8 | 247 | 2.9375 | 3 | [] | no_license | #include <iostream>
using namespace std;
int main(){
double numero;
int n1;
cout<<"Inserte el numero que desea saber el 20%: " <<endl;
cin>>n1;
numero = n1*20/100;
cout<<"Su resultado es: " << numero <<endl;
}
| true |
96fe616c86ccc0719d7f48b7ee8743d3ca977d12 | C++ | gusenov/examples-cpp | /tpl/tpl-method-spec/main.cc | UTF-8 | 589 | 2.84375 | 3 | [
"MIT"
] | permissive | #include <cstdio>
#include <cstdlib>
#include "TPrimitiveStorage.h"
int main(int argc, const char* argv[]) {
IPrimitiveStorage* primitiveStorage = new TPrimitiveStorage();
char* charPointer = primitiveStorage->GetPointerOf<char>();
*charPointer = 'A';
printf("char = '%c'\n", primitiveStorage->GetRefOfChar());
unsigned char* unsignedCharPointer = primitiveStorage->GetPointerOf<unsigned char>();
*unsignedCharPointer = 'B';
printf("unsigned char = '%c'\n", primitiveStorage->GetRefOfUnsignedChar());
delete primitiveStorage;
return EXIT_SUCCESS;
}
| true |
995d4a155cb2785072dd98936b636b386ba57da8 | C++ | jessicaione101/online-judge-solutions | /SPOJ/ELEICOES.cpp | UTF-8 | 507 | 2.90625 | 3 | [] | no_license | // http://br.spoj.com/problems/ELEICOES/
#include <iostream>
#include <map>
#include <utility>
#include <algorithm>
int main() {
int n;
std::cin >> n;
std::map<int, int> candidates;
int i;
for (int j = 0; j < n; ++j) {
std::cin >> i;
++candidates[i];
}
std::cout << (std::max_element(candidates.begin(), candidates.end(),
[](const std::pair<int, int>& p1, const std::pair<int, int>& p2) -> bool {
return p1.second < p2.second;
}))->first << std::endl;
return 0;
}
| true |
c256e319e21e12071345c08c5eb6427152cab179 | C++ | lemont037/URI | /Beginner/Average2.cpp | UTF-8 | 417 | 2.875 | 3 | [] | no_license | #include <iostream>
#include <iomanip>
using std::cin,
std::cout,
std::endl,
std::fixed,
std::setprecision;
int main(int argc, char const *argv[])
{
double a, b, c, avg;
int wA = 2,
wB = 3,
wC = 5;
cin >> a
>> b
>> c;
avg = (a*wA + b*wB + c*wC)/(wA+wB+wC);
cout << fixed << setprecision(1) << "MEDIA = " << avg << endl;
return 0;
}
| true |
dc2fb80d732b9be3be6d374287b904eb583a1b88 | C++ | markyang59/mkutility | /mkqueue.cpp | UTF-8 | 2,959 | 2.671875 | 3 | [] | no_license | #define WIN32_LEAN_AND_MEAN
#pragma once
#include "mkqueue.h"
#include "mkutil.h"
MKQ* mkq_create(int32_t sizemax)
{
MKQ* q = new MKQ;
q->sizemax = (sizemax == -1) ? MAXINT : sizemax;
q->sem_fill = ::CreateSemaphore(NULL, 0, q->sizemax, NULL);
q->sem_empty = ::CreateSemaphore(NULL, q->sizemax, q->sizemax, NULL);
q->evt_stop = ::CreateEvent (NULL, TRUE, FALSE,NULL);
::InitializeCriticalSection(&(q->cs));
return q;
}
bool mkq_delete(PBYTE p, bool (*destroyer)(PBYTE))
{
bool ret = false;
if (p != NULL)
{
MKQ* q = (MKQ*) p;
mkq_stop(q);
::EnterCriticalSection(&(q->cs));
while (!(q->ptr.empty()))
{
PBYTE ret = q->ptr.front();
q->ptr.pop_front();
if (destroyer != NULL)(*destroyer)(ret);
}
::LeaveCriticalSection(&(q->cs));
::CloseHandle(q->sem_fill);
::CloseHandle(q->sem_empty);
::CloseHandle(q->evt_stop);
::DeleteCriticalSection(&(q->cs));
q->sizemax = -1;
delete q;
ret = true;
}
return ret;
}
PBYTE mkq_push(MKQ* q, PBYTE p, bool wait)
{
PBYTE ret = NULL;
if (q != NULL && p != NULL)
{
if (wait && GetEvent(q->evt_stop) == false)
{
HANDLE hs[] = { q->sem_empty, q->evt_stop };
DWORD sig = ::WaitForMultipleObjects(2, hs, false, INFINITE);
}
::EnterCriticalSection(&(q->cs));
if ((q->sizemax > 0) && ((int32_t)(q->ptr.size()) > q->sizemax))
{
ret = q->ptr.front();
q->ptr.pop_front();
}
q->ptr.push_back(p);
::LeaveCriticalSection(&(q->cs));
::ReleaseSemaphore(q->sem_fill, 1, NULL); // inc sem
}
return ret;
}
PBYTE mkq_pop(MKQ* q, bool wait)
{
PBYTE ret = NULL;
if (q != NULL)
{
if (wait && GetEvent(q->evt_stop) == false)
{
HANDLE hs[] = { q->sem_fill, q->evt_stop };
DWORD sig = ::WaitForMultipleObjects(2, hs, false, INFINITE);
}
::EnterCriticalSection(&(q->cs));
if (!(q->ptr.empty()))
{
ret = q->ptr.front();
q->ptr.pop_front();
}
::LeaveCriticalSection(&(q->cs));
::ReleaseSemaphore(q->sem_empty, 1, NULL);
}
return ret;
}
void mkq_stop(MKQ* q)
{
::SetEvent(q->evt_stop);
}
PBYTE mkq_front(MKQ* q)
{
PBYTE ret = NULL;
if (!(q->ptr.empty()))
{
::EnterCriticalSection(&(q->cs));
ret = q->ptr.front();
::LeaveCriticalSection(&(q->cs));
}
return ret;
}
bool mkq_empty(MKQ* q)
{
return q->ptr.empty();
}
PBYTE mkq_nth(MKQ* q, uint32_t n)
{
PBYTE ret = NULL;
if ((q != NULL) && (!(q->ptr.empty())) && (n < q->ptr.size()))
{
::EnterCriticalSection(&(q->cs));
ret = q->ptr.at(n);
::LeaveCriticalSection(&(q->cs));
}
return ret;
}
bool mkq_erase(MKQ* q, uint32_t n)
{
bool ret = false;
if ((q != NULL) && (!(q->ptr.empty())) && (n < q->ptr.size()))
{
::EnterCriticalSection(&(q->cs));
q->ptr.erase(q->ptr.begin() + n);
::LeaveCriticalSection(&(q->cs));
}
return ret;
}
bool mkq_clear(MKQ* q, bool (*destroyer)(PBYTE))
{
PBYTE item = mkq_pop(q,false);
while(item != NULL)
{
if (destroyer != NULL)(*destroyer)(item);
item = mkq_pop(q,false);
}
return true;
}
| true |
49aaded524c902ae333986a1207b0ece709b4f74 | C++ | Amos-Q/Code | /2020_5_17/2020_5_17/test.cpp | GB18030 | 2,134 | 3.234375 | 3 | [] | no_license | #define _CRT_SECURE_NO_WARNINGS 1
#include <vector>
#include <string>
using namespace std;
class AClass
{
public:
int num;
string name;
};
struct AStruct
{
int num;
string name;
};
void TestStruct()
{
//ʹ
AClass Ac;
vector<AClass> vc;
Ac.num = 10;
Ac.name = "name";
vc.push_back(Ac);
AClass d;
for (vector<AClass>::iterator it = vc.begin(); it < vc.end(); ++it)
{
d = *it;
cout << d.num << endl;
}
//ṹʹ
AStruct As;
vector<AStruct> vs;
As.num = 10;
As.name = "name";
vs.push_back(As);
AStruct ds;
for (vector<AStruct>::iterator it = vs.begin(); it < vs.end(); ++it)
{
ds = *it;
cout << ds.num << endl;
}
}
void TestPoint()
{
//ʹ
AClass *Ac = new AClass;
vector<AClass *> vc;
Ac->num = 10;
Ac->name = "name";
vc.push_back(Ac);
AClass *d;
for (vector<AClass*>::iterator it = vc.begin(); it < vc.end(); ++it)
{
d = *it;
cout << d->num << endl;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
TestStruct();
TestPoint();
int n;
cin >> n;
return 0;
}
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
vector<int> v;
for (int i = 0; i < 10; i++) {
v.push_back(i);
}
for (vector<int>::size_type ix = 0; ix != v.size(); ix++) {
printf("%d\t", v[ix]);
}
printf("\n");
//ڿʼ10,10,10
v.insert(v.begin(), 3, 10);
for (vector<int>::size_type ix = 0; ix != v.size(); ix++) {
printf("%d\t", v[ix]);
}
printf("\n");
//ɾڶ10
int i = 0;
vector<int>::iterator it;
for (it = v.begin(); it != v.end(); it++) {
i++;
if (i == 2) {
v.erase(it);
break;
}
}
for (vector<int>::size_type ix = 0; ix != v.size(); ix++) {
printf("%d\t", v[ix]);
}
printf("\n");
return 0;
}
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
vector<int> v;
for (int i = 0; i < 10; i++) {
v.push_back(i);
}
//±
for (vector<int>::size_type ix = 0; ix != v.size(); ix++) {
printf("%d\t", v[ix]);
}
printf("\n");
//õ
vector<int>::iterator it;
for (it = v.begin(); it != v.end(); it++) {
printf("%d\t", *it);
}
printf("\n");
return 0;
} | true |
4c5cc15e3317bc4494e174109a19e2428e2078f4 | C++ | Larzid/PRIME | /src/Skills.cpp | UTF-8 | 10,625 | 2.609375 | 3 | [] | no_license | /*******************************
Skill Management Code
each character has access to a variety of skills
********************************/
#include "Global.h"
#include "Util.h"
#include "Object.h"
#include "Hero.h"
#include "Interface.h"
int
shSkill::getValue () const
{
return mRanks + mBonus;
}
const char *
shSkill::getName () const
{
if (mPower) return getMutantPowerName (mPower);
switch (mCode) {
/* Combat */
case kGrenade: return "Thrown Weapons";
case kHandgun: return "Handguns";
case kLightGun: return "Light Guns";
case kHeavyGun: return "Heavy Guns";
case kUnarmedCombat: return "Unarmed Combat";
case kMeleeWeapon: return "Basic Melee Weapons";
case kSword: return "Swords";
case kPowerArmor: return "Power Armor Training";
/* Adventuring */
case kConcentration: return "Concentration";
case kOpenLock: return "Pick Locks";
case kRepair: return "Repair";
case kSearch: return "Search";
case kHacking: return "Programming";
case kSpot: return "Spot";
/* Metapsychic faculties */
case kMFFarsenses: return "Farsenses";
case kMFTelekinesis: return "Telekinesis";
case kMFCreativity: return "Creativity";
case kMFRedaction: return "Redaction";
case kMFCoercion: return "Coercion";
case kMFTranslation: return "Translation";
default:
return "Unknown!";
}
}
#if 0
static int
compareSkills (shSkill **a, shSkill **b)
{
shSkill *s1 = * (shSkill **) a;
shSkill *s2 = * (shSkill **) b;
if (s1->mCode < s2->mCode) {
return -1;
} else if (s1->mCode > s2->mCode) {
return 1;
} else if (s1->mPower < s2->mPower) {
return -1;
} else {
return 1;
}
}
#endif
void
shSkill::getDesc (char *buf, int len) const
{
const char *abilname = NULL;
switch (kSkillAbilityMask & mCode) {
case kStrSkill: abilname = "Str"; break;
case kConSkill: abilname = "Con"; break;
case kAgiSkill: abilname = "Agi"; break;
case kDexSkill: abilname = "Dex"; break;
case kIntSkill: abilname = "Int"; break;
case kPsiSkill: abilname = "Psi"; break;
}
int abil;
if (mCode == kMutantPower)
abil = MutantPowers[mPower].mAbility;
else
abil = Hero.cr ()->mAbil.totl (SKILL_KEY_ABILITY (mCode));
int mod = mBonus + ABILITY_MODIFIER (abil);
int max = mAccess * (Hero.cr ()->mCLevel + 1) / 4;
snprintf (buf, len, "%-26s %s %2d/%2d %+3d %+3d ",
getName (), abilname, mRanks, max, mod, mod+mRanks);
}
static const char *
prepareHeader (const char *hdr, bool choice)
{
char *buf = GetBuf ();
snprintf (buf, SHBUFLEN, "%s %-22s Abil. Ranks Mod Tot ",
choice ? "Pick " : "", hdr);
return buf;
}
static void
describeSkill (const void *skill)
{
extern const char *getCodename (const char *); /* Help.cpp */
assert (skill);
const shSkill *s = (shSkill *) (skill);
const char *desc = s->getName ();
const char *buf = getCodename (desc);
shTextViewer *viewer = new shTextViewer (buf);
viewer->show ();
delete viewer;
}
void
shCreature::editSkills ()
{
char prompt[50];
int i;
int flags = shMenu::kSelectIsPlusOne | shMenu::kCountAllowed | shMenu::kShowCount;
int navail = 0;
char buf[70];
shSkill *skill;
shSkillCode lastcode = kUninitializedSkill;
// mSkills.sort (&compareSkills);
do {
if (mSkillPoints > 1) {
snprintf (prompt, 50, "You may make %d skill advancements:",
mSkillPoints);
flags |= shMenu::kMultiPick;
} else if (mSkillPoints == 1) {
snprintf (prompt, 50, "You may advance a skill:");
flags |= shMenu::kMultiPick;
} else {
snprintf (prompt, 50, "Skills");
flags |= shMenu::kNoPick;
}
shMenu *menu = I->newMenu (prompt, flags);
//menu->attachHelp ("skills.txt");
menu->attachHelp (describeSkill);
char letter = 'a';
for (i = 0; i < mSkills.count (); i++) {
skill = mSkills.get (i);
skill->getDesc (buf, 70);
int category = skill->mCode & kSkillTypeMask;
if (category == kMutantPower and !mMutantPowers[skill->mPower])
continue; /* Learn the power first. */
/* Choose header if appropriate. */
if (category != kMutantPower) {
if ((lastcode & kSkillTypeMask) != category) {
const char *header;
switch (category) {
case kWeaponSkill:
header = "Combat"; break;
case kAdventureSkill:
header = "Adventuring"; break;
case kMetapsychicFaculty:
header = "Metapsychic Faculties"; break;
default:
header = "UNKNOWN"; break;
}
menu->addHeader (prepareHeader (header, true));
}
} else {
const int mask = (kSkillTypeMask | kSkillNumberMask);
if ((lastcode & mask) != (skill->mCode & mask)) {
char *buf = GetBuf ();
/* Transform mutant power skill to metapsychic faculty. */
int code = (skill->mCode & kSkillNumberMask) | kMetapsychicFaculty | kPsiSkill;
shSkill *temp = new shSkill (shSkillCode (code));
snprintf (buf, SHBUFLEN, "Power (%s)", temp->getName ());
delete temp;
menu->addHeader (prepareHeader (buf, true));
}
}
lastcode = skill->mCode;
int max = skill->mAccess*(mCLevel+1)/4;
if (mSkillPoints and max > skill->mRanks) {
menu->addPtrItem (letter++, buf, skill,
mini (mSkillPoints, max - skill->mRanks));
navail++;
if (letter > 'z') letter = 'A';
} else {
menu->addPtrItem (0, buf, skill);
}
}
int advanced = 0;
do {
int count;
i = menu->getPtrResult ((const void **) &skill, &count);
if (skill) {
if (count > mSkillPoints) count = mSkillPoints;
mSkillPoints -= count;
skill->mRanks += count;
advanced++;
}
} while (i and mSkillPoints);
delete menu;
if (!advanced)
break;
computeSkills ();
computeIntrinsics (); /* For improving Haste for example. */
I->drawSideWin (this);
} while (mSkillPoints);
/* Do computation again to be sure. */
// TODO: figure out if this paranoia is really needed.
computeSkills ();
computeIntrinsics ();
}
void
shCreature::computeSkills ()
{
for (int i = 0; i < mSkills.count (); ++i) {
shSkill *s = mSkills.get (i);
s->mBonus = 0;
}
for (int i = 0; i < mInventory->count (); ++i) {
shObject *obj = mInventory->get (i);
obj->applyConferredSkills (this);
}
if (usesPower (kDeepsight)) {
int skill = getSkillModifier (kMutantPower, kDeepsight);
int mod = maxi (1, 1 + skill / 4);
shSkill *s = getSkill (kRepair);
s->mBonus += mod;
s = getSkill (kOpenLock);
s->mBonus += mod;
s = getSkill (kHacking);
s->mBonus += mod;
}
}
shSkill *
shCreature::getSkill (shSkillCode c, shMutantPower power)
{
if (power and mMutantPowers[power] == MUT_POWER_ABSENT)
return NULL;
for (int i = 0; i < mSkills.count (); ++i) {
shSkill *s = mSkills.get (i);
if (power) {
if (power == s->mPower)
return s;
} else if (c == s->mCode)
return s;
}
return NULL;
}
int
shCreature::getSkillModifier (shSkillCode c,
shMutantPower power)
{
int result = 0;
shSkill *skill;
abil::Index ability;
if (c == kMutantPower) {
skill = getSkill (c, power);
ability = MutantPowers[power].mAbility;
} else {
skill = getSkill (c);
ability = SKILL_KEY_ABILITY (c);
}
result += ABILITY_MODIFIER (mAbil.totl (ability));
if (skill) {
result += skill->mRanks + skill->mBonus;
}
if (is (kSickened)) {
result -= 2;
}
return result;
}
int
shCreature::getWeaponSkillModifier (shObjectIlk *ilk, shAttack *atk)
{
shSkillCode c = kNoSkillCode;
shSkill *skill = NULL;
abil::Index ability = abil::Dex;
int result = 0;
if (NULL == ilk) { /* Barehanded. */
c = kUnarmedCombat;
} else {
c = ilk->getSkillForAttack (atk);
if (c == kNoSkillCode and atk->isMeleeAttack ()) {
/* Improvised melee weapon. */
ability = abil::Str;
result -= 4;
}
}
if (c != kNoSkillCode) {
ability = SKILL_KEY_ABILITY (c);
skill = getSkill (c);
}
result += mToHitModifier;
result += ABILITY_MODIFIER (mAbil.totl (ability));
/* I have no idea why deviations from kMedium give bonuses. -- MB */
switch (getSize ()) {
case kFine: result += 8; break;
case kDiminutive: result += 4; break;
case kTiny: result += 2; break;
case kSmall: result += 1; break;
case kMedium: break;
case kLarge: result += 1; break;
case kHuge: result += 2; break;
case kGigantic: result += 4; break;
case kColossal: result += 8; break;
default:
I->p ("getWeaponSkillModifier: unknown size!");
I->p ("Please file a bug report.");
return -4;
}
if (NULL == skill or (0 == skill->mRanks and 0 >= skill->mBonus)) {
/* inflict a slight penalty for lacking weapon skill,
since we're not using SRD Feats */
result -= 2;
} else {
result += skill->mRanks + skill->mBonus;
}
if (is (kSickened)) {
result -= 2;
}
return result;
}
void
shCreature::gainRank (shSkillCode c, int howmany, shMutantPower power)
{
shSkill *skill = getSkill (c, power);
if (!skill) {
skill = new shSkill (c, power);
mSkills.add (skill);
}
skill->mRanks += howmany;
}
void
shCreature::addSkill (shSkillCode c, int access, shMutantPower power)
{
shSkill *skill = new shSkill (c, power);
skill->mAccess = access;
mSkills.add (skill);
}
| true |
f839c60f32ef9a0e97fd82743546f06d9b409d58 | C++ | 257786/ProgramowanieObiektowe | /plik.cpp | UTF-8 | 2,746 | 2.9375 | 3 | [] | no_license | //
// plik.cpp
// ##5
//
// Created by yaroslav on 01/05/2021.
//
#include <iostream>
#include "plik.h"
#include "tablica.h"
using namespace std;
outPlik::outPlik(string path)
{
this->path = path;
open();
}
void outPlik::open()
{
plik.open(path);
}
void outPlik::close()
{
plik.close();
}
inPlik::inPlik(string path)
{
this->path = path;
open();
}
void inPlik::open()
{
plik.open(this->path);
}
void inPlik::open(string path)
{
this->path = path;
open();
}
//Metod zapisujący tablicę do pliku
void outPlik::save( sheet arr)
{
for (int i = 0; i < arr.getRows(); i++)
{
for(int j = 0; j < arr.getColums(); j++)
{
plik << arr.showPoint(j, i) << "\t";
}
plik << endl;
}
}
void inPlik::close()
{
plik.close();
}
//Funkcja zwracająca ilość wierszy w pliku
int inPlik::getRows1()
{
char ch;
int rows = 0;
open();
plik.seekg(plik.beg);
while(plik.get(ch))
if((ch == 0x0a) || (ch == 0x03) || (ch == 0x00) || (ch == 0x04))
rows++;
plik.clear();
plik.seekg(0);
close();
return rows;
}
//Funkcja zwracająca ilość kolum w pliku
int inPlik::getColums1()
{
char ch;
int colums = 0;
open();
plik.seekg(plik.beg);
while(plik.get(ch) && ch != 0x0A)
if(ch == 0x09)
colums++;
plik.clear();
plik.seekg(plik.beg);
close();
return colums;
}
//Funkcla zwracająca ilość kolum w pliku
int inPlik::getColums()
{
getColums1();
return getColums1()+1;
}
//Funkcja zwracająca ilość wierszy w pliku
int inPlik::getRows()
{
getColums1();
return getRows1();
}
//Funkcja zwracająca danne konkretnej komurki w tablice z pliku
string inPlik::showPoint(const int x, const int y)
{
open();
plik.seekg(plik.beg);
plik.clear();
char ch;
int p = (y - 1) * getColums() + x - 1;
string val;
close();
open();
for (int i = 0; (i < p) && plik.get(ch); i+0)
{
if (ch == 0x09 || ch == 0x0A)
i++;
}
do
{
plik.get(ch);
if(ch != 0x09 && ch != 0x0A)
val += ch;
}
while (ch != 0x09 && ch != 0x0A);
close();
return val;
}
//Metod, który dopasowuję rozmiar tablicy dynamicznej do rozmiaru tablicy w pliku
void inPlik::goSize(sheet &arr)
{
arr.edit_size(getRows(), getColums());
}
//Metod, który importuję tablicę z pliku
void inPlik::import(sheet &arr)
{
goSize(arr);
for(int i = 0; i < arr.getRows(); i++)
{
for(int j = 0; j < arr.getColums(); j++)
{
arr.writePoint(i, j , showPoint(j+1, i+1));
}
}
}
bool inPlik::is()
{
return plik.is_open();
} | true |
55bb088886cdf70b94e6dac80ca5d18496b21132 | C++ | miha53cevic/CPP | /RandomPracticeProjects/SimplePassOrFail.cpp | UTF-8 | 248 | 2.765625 | 3 | [] | no_license | #include <iostream>
using namespace std;
int main (){
int n;
cout << "Enter your score: ";
cin >> n;
if (n >= 50 && n < 80) cout << "\nPass!";
else if (n >=80) cout << "\nGreat Job";
else if (n <= 20) cout << "\nFail";
}
| true |
6782e44aac9930cd7fe8d393285056e3ef8ef5da | C++ | qinting513/Learning-QT | /2016 Plan/数据结构代码/第6章 树和二叉树/bo6-3.cpp | GB18030 | 4,774 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | // bo6-3.cpp (洢ṹc6-2.h)Ļ(18)㷨6.26.4
Status BiTreeEmpty(BiTree T)
{
if(T)
return FALSE;
else
return TRUE;
}
int BiTreeDepth(BiTree T)
{
int i,j;
if(!T)
return 0;
i=BiTreeDepth(T->lchild);
j=BiTreeDepth(T->rchild);
return i>j?i+1:j+1;
}
TElemType Root(BiTree T)
{
if(BiTreeEmpty(T))
return Nil;
else
return T->data;
}
TElemType Value(BiTree p)
{
return p->data;
}
void Assign(BiTree p,TElemType value)
{
p->data=value;
}
typedef BiTree QElemType;
#include"c3-2.h"
#include"bo3-2.cpp"
BiTree Point(BiTree T,TElemType s)
{
LinkQueue q;
QElemType a;
if(T)
{ InitQueue(q);
EnQueue(q,T);
while(!QueueEmpty(q))
{ DeQueue(q,a);
if(a->data==s)
{
DestroyQueue(q);
return a;
}
if(a->lchild)
EnQueue(q,a->lchild);
if(a->rchild)
EnQueue(q,a->rchild);
}
DestroyQueue(q);
}
return NULL;
}
TElemType LeftChild(BiTree T,TElemType e)
{
BiTree a;
if(T)
{ a=Point(T,e);
if(a&&a->lchild)
return a->lchild->data;
}
return Nil;
}
TElemType RightChild(BiTree T,TElemType e)
{
BiTree a;
if(T)
{ a=Point(T,e);
if(a&&a->rchild)
return a->rchild->data;
}
return Nil;
}
Status DeleteChild(BiTree p,int LR)
{
if(p)
{ if(LR==0)
ClearBiTree(p->lchild);
else if(LR==1)
ClearBiTree(p->rchild);
return OK;
}
return ERROR;
}
void PostOrderTraverse(BiTree T,void(*Visit)(TElemType))
{
if(T)
{ PostOrderTraverse(T->lchild,Visit);
PostOrderTraverse(T->rchild,Visit);
Visit(T->data);
}
}
void LevelOrderTraverse(BiTree T,void(*Visit)(TElemType))
{
LinkQueue q;
QElemType a;
if(T)
{ InitQueue(q);
EnQueue(q,T);
while(!QueueEmpty(q))
{ DeQueue(q,a);
Visit(a->data);
if(a->lchild!=NULL)
EnQueue(q,a->lchild);
if(a->rchild!=NULL)
EnQueue(q,a->rchild);
}
printf("\n");
DestroyQueue(q);
}
}
void CreateBiTree(BiTree &T)
{
TElemType ch;
scanf(form,&ch);
if(ch==Nil)
T=NULL;
else
{ T=(BiTree)malloc(sizeof(BiTNode));
if(!T)
exit(OVERFLOW);
T->data=ch;
CreateBiTree(T->lchild);
CreateBiTree(T->rchild);
}
}
TElemType Parent(BiTree T,TElemType e)
{
LinkQueue q;
QElemType a;
if(T)
{ InitQueue(q);
EnQueue(q,T);
while(!QueueEmpty(q))
{ DeQueue(q,a);
if(a->lchild&&a->lchild->data==e||a->rchild&&a->rchild->data==e)
return a->data;
else
{ if(a->lchild)
EnQueue(q,a->lchild);
if(a->rchild)
EnQueue(q,a->rchild);
}
}
}
return Nil;
}
TElemType LeftSibling(BiTree T,TElemType e)
{
TElemType a;
BiTree p;
if(T)
{ a=Parent(T,e);
if(a!=Nil)
{ p=Point(T,a);
if(p->lchild&&p->rchild&&p->rchild->data==e)
return p->lchild->data;
}
}
return Nil;
}
TElemType RightSibling(BiTree T,TElemType e)
{
TElemType a;
BiTree p;
if(T)
{ a=Parent(T,e);
if(a!=Nil)
{ p=Point(T,a);
if(p->lchild&&p->rchild&&p->lchild->data==e)
return p->rchild->data;
}
}
return Nil;
}
Status InsertChild(BiTree p,int LR,BiTree c)
{
if(p)
{ if(LR==0)
{ c->rchild=p->lchild;
p->lchild=c;
}
else
{ c->rchild=p->rchild;
p->rchild=c;
}
return OK;
}
return ERROR;
}
typedef BiTree SElemType;
#include"c3-1.h"
#include"bo3-1.cpp"
void InOrderTraverse1(BiTree T,void(*Visit)(TElemType))
{
SqStack S;
InitStack(S);
while(T||!StackEmpty(S))
{ if(T)
{
Push(S,T);
T=T->lchild;
}
else
{ Pop(S,T);
Visit(T->data);
T=T->rchild;
}
}
printf("\n");
DestroyStack(S);
}
void InOrderTraverse2(BiTree T,void(*Visit)(TElemType))
{
SqStack S;
BiTree p;
InitStack(S);
Push(S,T);
while(!StackEmpty(S))
{ while(GetTop(S,p)&&p)
Push(S,p->lchild);
Pop(S,p);
if(!StackEmpty(S))
{ Pop(S,p);
Visit(p->data);
Push(S,p->rchild);
}
}
printf("\n");
DestroyStack(S);
}
| true |
72e3971d0fd7dc6e51f943e96e66d0c4014afd6c | C++ | codehz/mcpe-mods-dev | /src/uuid/main.cpp | UTF-8 | 3,018 | 2.671875 | 3 | [] | no_license | #include <string>
#include <sstream>
#include <climits>
#include <cstdio>
#include <ios>
#include <iomanip>
#include <minecraft/command/Command.h>
#include <minecraft/command/CommandMessage.h>
#include <minecraft/command/CommandOutput.h>
#include <minecraft/command/CommandParameterData.h>
#include <minecraft/command/CommandRegistry.h>
#include <minecraft/command/CommandVersion.h>
template <typename T>
std::string stringify(T const &t)
{
std::stringstream ss;
ss << t;
return ss.str();
}
struct UUID
{
short p2, p1;
unsigned p0, pr;
short p4, p3;
friend std::ostream &operator<<(std::ostream &os, const UUID &uuid)
{
os << std::hex << std::setfill('0') << std::setw(8)
<< uuid.p0 << '-' << std::setw(4)
<< uuid.p1 << '-' << std::setw(4)
<< uuid.p2 << '-' << std::setw(4)
<< uuid.p3 << '-' << std::setw(4)
<< uuid.p4 << std::setw(8) << uuid.pr;
return os;
}
};
struct Entity
{
unsigned int fillerX[1130];
UUID uuid;
const std::string &getNameTag() const;
};
struct Player : Entity
{
};
template <typename T>
struct CommandSelectorResults
{
std::shared_ptr<std::vector<T *>> content;
bool empty() const;
};
struct CommandSelectorBase
{
CommandSelectorBase(bool);
virtual ~CommandSelectorBase();
};
template <typename T>
struct CommandSelector : CommandSelectorBase
{
char filler[0x74];
CommandSelector();
const CommandSelectorResults<T> results(CommandOrigin const &) const;
};
struct CommandSelectorPlayer : CommandSelector<Player>
{
CommandSelectorPlayer() : CommandSelector() {}
~CommandSelectorPlayer() {}
static typeid_t<CommandRegistry> type_id()
{
static typeid_t<CommandRegistry> ret = type_id_minecraft_symbol<CommandRegistry>("_ZZ7type_idI15CommandRegistry15CommandSelectorI6PlayerEE8typeid_tIT_EvE2id");
return ret;
}
};
struct UuidCommand : Command
{
CommandSelectorPlayer target;
~UuidCommand() override = default;
static void setup(CommandRegistry ®istry)
{
registry.registerCommand("uuid", "UUID Query", (CommandPermissionLevel)0, (CommandFlag)0, (CommandFlag)0);
registry.registerOverload<UuidCommand>("uuid", CommandVersion(1, INT_MAX),
CommandParameterData(CommandSelectorPlayer::type_id(), &CommandRegistry::parse<CommandSelector<Player>>, "target", (CommandParameterDataType)0, nullptr, offsetof(UuidCommand, target), false, -1));
}
void execute(CommandOrigin const &origin, CommandOutput &outp) override
{
auto res = target.results(origin);
if (res.empty())
{
outp.addMessage("empty");
}
else
{
for (auto &ent : *res.content)
{
outp.addMessage(stringify(ent->uuid) + "#" + ent->getNameTag());
}
}
outp.success();
}
};
extern "C"
{
void setupCommands(CommandRegistry ®istry)
{
UuidCommand::setup(registry);
}
std::string *getUUID(Player *player) {
static std::string tmp;
tmp = stringify(player->uuid);
return &tmp;
}
} | true |
d17c35ca1fd7f294121fa4c73590a5841a98aff8 | C++ | chaosfreak93/LotteryBot | /main.cpp | UTF-8 | 1,812 | 2.890625 | 3 | [] | no_license | #include <iostream>
#include <windows.h>
#include <thread>
using namespace std;
int claim = 1;
int maxTickets = 0;
int totalTickets = 0;
int klickPerSeconds = 1;
void StartBot() {
Sleep(50);
for (int i = 1; i <= maxTickets; i++) {
SetCursorPos(375, 275);
Sleep(1000 / klickPerSeconds);
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
totalTickets++;
cout << "Round: " << claim << ", Total Tickets: " << totalTickets << ", Ticket: " << i << endl;
}
Sleep(50);
SetCursorPos(500, 275);
Sleep(100);
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
Sleep(100);
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
Sleep(100);
claim++;
StartBot();
}
void ShutdownHook() {
while (true) {
if (GetAsyncKeyState(VK_RCONTROL) != 0) {
exit(0);
}
}
}
int main() {
HWND hWnd = FindWindowW(nullptr, L"Minecraft 1.16.4 - Multiplayer (3rd-party Server)");
if (hWnd) {
cout << "Maximal Tickets pro Runde >>>";
cin >> maxTickets;
cout << "Klicks in Sekunde >>>";
cin >> klickPerSeconds;
SetWindowPos(hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
SetWindowPos(hWnd,HWND_NOTOPMOST,0,0,0,0,SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
MoveWindow(hWnd, 0, 0, 745, 520, true);
Sleep(100);
std::thread bot_thread([] { return StartBot(); });
std::thread shutdown_thread([] { return ShutdownHook(); });
bot_thread.join();
shutdown_thread.join();
return 0;
}
cout << "Window not found!" << endl;
Sleep(5000);
return -1;
}
| true |
d5aff919e63198e3ffb5a623069ce339f7032742 | C++ | blizzaaard/lc2016 | /square_number.cpp | UTF-8 | 1,511 | 3.46875 | 3 | [] | no_license | #include <iostream>
#include <vector>
#include <math.h>
using namespace std;
void print(const vector<int>& result)
{
for (int i = 0; i < result.size(); ++i) {
cout << result[i] << "^2";
if (i != result.size() - 1)
cout << '+';
}
cout << endl;
}
void helper(vector<int> *result, const vector<int>& trace, int n)
{
if (0 == trace[n]) {
int root = sqrt(n);
result->push_back(root);
} else {
helper(result, trace, trace[n]);
helper(result, trace, n - trace[n]);
}
}
vector<int> square_number(int n)
{
vector<int> trace(n + 1, 0);
// 0 indicates this number is a square number
vector<int> opt(n + 1, INT_MAX);
opt[0] = 1;
for (int i = 1; i <= n; ++i) {
int root = sqrt(i);
if (i == root * root) { // 'i' is a square number
opt[i] = 1;
} else { // 'i' is NOT a square number
for (int k = 1; k <= i / 2; ++k) {
if (opt[i] > opt[k] + opt[i - k]) {
opt[i] = opt[k] + opt[i - k];
trace[i] = k;
}
}
}
}
// Generate the result from the trace vector
vector<int> result;
helper(&result, trace, n);
return result;
}
int main()
{
int A[] = { 52, 1, 0, 100, 1000, 8237, 300, 100, 8 };
for (int i = 0; i < sizeof A / sizeof *A; ++i) {
cout << A[i] << '=';
print(square_number(A[i]));
cout << endl;
}
return 0;
}
| true |
a3e0bc5cc7a794ada8bfc41d9e3afc24ce87a519 | C++ | drewjbartlett/runescape-classic-dump | /eXemplar's-collection/exemplar/Apps 'n Bots/Apps 'n Bots/OCR/FOCRSource/src/KFC_KTL/suspendable.h | UTF-8 | 1,224 | 2.578125 | 3 | [] | no_license | #ifndef suspendable_h
#define suspendable_h
#include "basic_types.h"
#include "kfc_ktl_api.h"
// Activation suspension modes
#define ASM_NEVER (0)
#define ASM_ALWAYS (1)
#define ASM_DEFAULT (2) // ASM_ALWAYS for fullscreen, ASM_NEVER for windowed
// ------------
// Suspendable
// ------------
class KFC_KTL_API TSuspendable
{
private:
size_t m_szSuspendCount;
protected:
virtual bool OnSuspend ();
virtual bool OnResume ();
public:
TSuspendable();
void ResetSuspendCount(size_t szSSuspendCount = 0);
bool SetSuspendCount(size_t szSSuspendCount);
bool Suspend();
bool Resume ();
// ---------------- TRIVIALS ----------------
size_t GetSuspendCount() const { return m_szSuspendCount; }
bool IsSuspended() const { return m_szSuspendCount ? true : false; }
};
// ----------
// Suspender
// ----------
class KFC_KTL_API TSuspender
{
private:
TSuspendable* m_pSuspendable;
public:
TSuspender(TSuspendable& SSuspendable);
~TSuspender();
// ---------------- TRIVIALS ----------------
TSuspendable* GetSuspendable() const { return m_pSuspendable; }
bool HasSucceeded() const { return m_pSuspendable != NULL; }
};
#endif // suspendable_h
| true |
4af3245ecbcad9c8d105058eb4d3af67adf64a39 | C++ | Bodo171/Sports-Tracker | /src/repository.cpp | UTF-8 | 4,091 | 3.109375 | 3 | [] | no_license | #include "repository.h"
static int emptyCallback(void* data, int argc, char** argv, char** azColName) {
return 0;
}
int getElementCallback(void* data, int argc, char** argv, char** azColName) {
Repository* myRepository=(Repository*) data;
myRepository->getEventFromDatabase(argc,argv,azColName);
return 0;
}
Repository::Repository() {
sqlite3_open(databaseName.c_str(), &database);
char* errorMessage=0;
string primaryKey = "PRIMARY KEY ( "+nameColumn+","+dateColumn+")";
string command = "CREATE TABLE IF NOT EXISTS " + tableName + " " + " ( "
+ nameColumn + " TEXT NOT NULL, " \
+ sportColumn + " TEXT, " \
+ dateColumn + " TEXT NOT NULL, "\
+ descriptionColumn+ " TEXT, "\
+ primaryKey + ");";
int exitCode=sqlite3_exec(database, command.c_str(), emptyCallback, 0, &errorMessage);
if (exitCode != SQLITE_OK) {
throw Error("Please restart");
}
}
//C-style API for sqlite
void Repository::getEventFromDatabase(int numberOfArguments, char** argumentValues, char** argumentNames) {
string name, description, sport;
Date date;
for (int i = 0; i < numberOfArguments; i++) {
string currentColumn(argumentNames[i]), currentValue(argumentValues[i]);
if (currentColumn == nameColumn)
name = currentValue;
if (currentColumn == descriptionColumn)
description = currentValue;
if (currentColumn == sportColumn)
sport = currentValue;
if (currentColumn == dateColumn)
date.fromString(currentValue);
}
events.push_back(Event(date,name,description,sport));
}
void Repository::addEvent(Event toAdd) {
string columns = " (" + nameColumn + "," + sportColumn + ", " +descriptionColumn+", "+dateColumn+")";
string values = "('"+toAdd.getName()+"', '"+toAdd.getSport()+"', '"+toAdd.getDescription()+"', '"+toAdd.getDate().toString()+"')";
string command = "INSERT INTO " + tableName +" "+columns+ " VALUES "+values+" ;";
char* errorMessage = 0;
int exitCode=sqlite3_exec(database, command.c_str(), emptyCallback, this,&errorMessage);
if (exitCode!=SQLITE_OK) {
string myErrorMessage(errorMessage);
sqlite3_free(errorMessage);
throw Error(myErrorMessage);
}
}
void Repository::removeEvent(Event toRemove) {
string nameCondition = nameColumn+" = '"+toRemove.getName()+"'";
string sportCondition = sportColumn+" = '"+toRemove.getSport()+"'";
string dateCondition = dateColumn+" = '"+toRemove.getDate().toString()+"'";
char* errorMessage = 0;
string command = "DELETE FROM " + tableName+" WHERE "+nameCondition+" AND "+sportCondition+ " AND "+dateCondition+" ;";
int exitCode = sqlite3_exec(database, command.c_str(), emptyCallback, this, &errorMessage);
if (exitCode!=SQLITE_OK) {
string myErrorMessage(errorMessage);
sqlite3_free(errorMessage);
throw Error(myErrorMessage);
}
}
bool Repository::isInRepository(Event toCheck) {
string nameCondition = nameColumn + " = " + "'"+toCheck.getName()+"'";
string sportCondition = sportColumn + " = " + "'"+toCheck.getSport()+"'";
string dateCondition = dateColumn + " = " + "'"+toCheck.getDate().toString()+"'";
char* errorMessage = 0;
string command = "SELECT * FROM " + tableName + " WHERE " + nameCondition + " AND " + sportCondition + " AND " + dateCondition+" ;";
int exitCode = sqlite3_exec(database, command.c_str(), getElementCallback, this, &errorMessage);
if (exitCode != SQLITE_OK) {
string myErrorMessage(errorMessage);
sqlite3_free(errorMessage);
throw Error(myErrorMessage);
}
bool toReturn = (events.size()>0);
events.clear();
return toReturn;
}
vector<Event> Repository::getAllEventsFromSport(string sport) {
char* errorMessage = 0;
string sportCondition = sportColumn + " = " + "'"+sport+"'";
string command = "SELECT * from " + tableName+ " WHERE " + sportCondition +" ;";
int exitCode = sqlite3_exec(database, command.c_str(), getElementCallback, this, &errorMessage);
if (exitCode != SQLITE_OK) {
string myErrorMessage(errorMessage);
sqlite3_free(errorMessage);
throw Error(myErrorMessage);
}
vector<Event> toReturn = events;
events.clear();
return toReturn;
}
Repository::~Repository() {
sqlite3_close(database);
} | true |
6fe15e20f9672b38d7a73b019ae1c6eea6a1fc18 | C++ | pce913/Algorithm | /baekjoon/2141.cpp | UHC | 473 | 2.875 | 3 | [] | no_license | #include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
vector< pair<int, int> > a;
//߾Ӱ ãָ ȴ.
int main(){
int n;
long long sum = 0, s = 0;
scanf("%d",&n);
for (int i = 0; i < n; i++){
int x, y;
scanf("%d %d",&x,&y);
a.push_back({ x, y });
sum += y;
}
sort(a.begin(), a.end());
for (int i = 0; i < a.size(); i++){
s += a[i].second;
if (s >= sum / 2){
printf("%d",a[i].first);
break;
}
}
return 0;
} | true |
a5596f620e0e5fa3f1ffa77ae5ecdafe4cf266e7 | C++ | verdande2/CST136-Spring-12 | /inLab 6 pt II/main.cpp | WINDOWS-1252 | 427 | 2.890625 | 3 | [] | no_license | #include "Fraction.h"
int main(){
Fraction f1;
Fraction f2(2L, 0L);
Fraction f3(f2);
cout << f1 << endl;
cout << f2 << endl;
cout << f3 << endl;
f3 = f3 + Fraction(-5, 4);
f1 = f2 + f3;
cout << f1 << endl;
f1 = f2 - f3;
cout << f1 << endl;
f1 = f2 * f3;
cout << f1 << endl;
cout << (f1++)++ << endl; // Whats going on notice the chaining
f1 = f2 / f3;
cout << f1 << endl;
system("pause");
return 0;
} | true |
14a60579b4bfc11c5f794b218d755f785202f458 | C++ | KORYUOH/koryuohproject-svn-server | /Additional_Class/Additional_Class/Koryuoh/Utility/ClassCheck/Utility.h | SHIFT_JIS | 1,028 | 2.84375 | 3 | [] | no_license | /**===File Commentary=======================================*/
/**
* @file Utility.h
*
* @brief [eB[wb_
*
* @author KORYUOH
*
* @date 2012/05/10
*/
/**===Include Guard========================================*/
#ifndef _UTILITY_H_
#define _UTILITY_H_
/**===File Include=========================================*/
namespace KORYUOH{
/**========================================================*/
/**
* @brief w肳ꂽNX`FbN
* @param[in] `FbN|C^ :typeid(*pointer)
* @note `FbNNXw肷邱
* @note :isClass<`FbNNX>(typeid(*pointer))
* @return w肳ꂽNXȂ^
*/
/**========================================================*/
template<class _Ty>
bool isClass(const type_info& info);
};
/**===End Class Definition=================================*/
#endif
/**===End Of File==========================================*/ | true |
cd995565b2cfff9ecaa0f0e3e13061067999f673 | C++ | rAzoR8/SpvGenTwo | /dis/source/dis.cpp | UTF-8 | 2,274 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #include "spvgentwo/Logger.h"
#include "spvgentwo/Module.h"
#include "spvgentwo/Grammar.h"
#include "common/HeapAllocator.h"
#include "common/BinaryFileWriter.h"
#include "common/BinaryFileReader.h"
#include "common/ConsoleLogger.h"
#include "common/ModulePrinter.h"
#include <cstring>
#include <cstdio>
using namespace spvgentwo;
using namespace ModulePrinter;
int main(int argc, char* argv[])
{
ConsoleLogger logger;
logger.logInfo("SpvGenTwoDisassembler by Fabian Wahlster - https://github.com/rAzoR8/SpvGenTwo");
const char* spv = nullptr;
const char* tabs = "\t\t";
bool serialize = false; // for debugging
bool reassignIDs = false;
bool colors = false;
PrintOptions options{ PrintOptionsBits::All };
for (int i = 1u; i < argc; ++i)
{
const char* arg = argv[i];
if (spv == nullptr)
{
spv = arg;
}
else if (strcmp(arg, "-serialize") == 0)
{
serialize = true;
}
else if (strcmp(arg, "-assignIDs") == 0 || strcmp(arg, "-assignids") == 0)
{
reassignIDs = true;
}
else if (strcmp(arg, "-noinstrnames") == 0)
{
options ^= PrintOptionsBits::InstructionName;
}
else if (strcmp(arg, "-noopnames") == 0)
{
options ^= PrintOptionsBits::OperandName;
}
else if (strcmp(arg, "-nopreamble") == 0)
{
options ^= PrintOptionsBits::Preamble;
}
else if (strcmp(arg, "-colors") == 0)
{
colors = true;
}
else if (i+1 < argc && strcmp(arg, "-tabs") == 0)
{
tabs = argv[++i];
}
}
if (spv == nullptr)
{
return -1;
}
HeapAllocator alloc;
if (BinaryFileReader reader(alloc, spv); reader)
{
Module module(&alloc, &logger);
Grammar gram(&alloc);
// parse the binary instructions & operands
if (module.readAndInit(reader, gram) == false)
{
return -1;
}
if (reassignIDs)
{
module.assignIDs(); // compact ids
}
auto printer = ModulePrinter::ModuleSimpleFuncPrinter([](const char* _pStr) { printf("%s", _pStr); }, colors);
const bool success = ModulePrinter::printModule(module, gram, printer, options, tabs);
if (success == false)
{
return -1;
}
if (serialize)
{
if (BinaryFileWriter writer(alloc, "serialized.spv"); writer.isOpen())
{
module.finalizeAndWrite(writer);
}
}
}
else
{
logger.logError("Failed to open %s", spv);
}
return 0;
} | true |
9cba421f702254ffe3c9ed876eb649360b0d77d7 | C++ | Shreyash-bit/Cpp-for-beginers | /tutorial20.cpp | UTF-8 | 556 | 3.15625 | 3 | [] | no_license | //============================================================================
// Name : tutorial20.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
inline int add(int a, int b)
{
return (a+b);
}
int sum(int x, int y, int z=0, int w=0)
{
return (x+y+z+w);
}
int main()
{
cout<<"4 + 5 = "<<add(4,5)<<endl;
cout<<"- sum ="<<sum(1,2);
return 0;
}
| true |
49ac5641f61a0b3bded9c439e50538588d76cf3f | C++ | ananevans/CarND-PID-Control-Project | /src/PID.cpp | UTF-8 | 908 | 2.890625 | 3 | [
"MIT"
] | permissive | #include "PID.h"
#include <iostream>
/**
*
* TODO: Complete the PID class. You may add any additional desired functions.
*/
PID::PID(double target) {
this->target = target;
reset_errors();
}
PID::~PID() {}
void PID::Init(double Kp_, double Ki_, double Kd_) {
/**
* TODO: Initialize PID coefficients (and errors, if needed)
*/
this->Kp = Kp_;
this->Ki = Ki_;
this->Kd = Kd_;
}
void PID::UpdateError(double cte) {
/**
* Update PID errors based on cte.
*/
d_error = cte - p_error;
i_error = i_error + cte;
p_error = cte;
}
double PID::TotalError() {
/**
* TODO: Calculate and return the total error
*/
return target - Kp * p_error - Kd * d_error - Ki * i_error;
}
void PID::debug_info() {
std::cout << "kp " << Kp << " " << "ki " << Ki << " " << "kd " << Kd << "\n";
}
void PID::reset_errors() {
this->d_error = 0.0;
this->p_error = 0.0;
this->i_error = 0.0;
}
| true |
4fa52a9a10231ddee82d02de4121225da541948f | C++ | tomault/inverted_penguin | /src/main/cpp/inverted_penguin/core/trie/detail/ByteTrieNode.hpp | UTF-8 | 2,736 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | #ifndef __INVERTEDPENGUIN__CORE__DETAIL__BYTETRIENODE_HPP__
#define __INVERTEDPENGUIN__CORE__DETAIL__BYTETRIENODE_HPP__
#include <inverted_penguin/core/detail/ByteTrieNodePosition.hpp>
#include <inverted_penguin/core/detail/ByteTrieBuilderKeyBuilder.hpp>
#include <limits>
#include <stdint.h>
namespace inverted_penguin {
namespace core {
namespace detail {
template <typename Value>
class ByteTrieNode {
public:
typedef ByteTrieNodePosition Position;
typedef ByteTrieBuilderKeyBuilder KeyBuilder;
static constexpr const uint32_t TYPE_MASK = Location::TYPE_MASK;
static constexpr const uint32_t NODE_ALIGNMENT = 4;
static constexpr const size_t VALUE_ALIGNMENT = alignof(Value);
static constexpr const size_t MAX_TRIE_SIZE =
std::numeric_limits<uint32_t>::max();
public:
ByteTrieNode(const uint8_t* base, uint32_t nodeOffset):
base_(base), start_(base + nodeOffset) {
}
uint32_t trieOffsetOnly() const { return (uint32_t)(start_ - base_); }
Position end() const { return Position(); }
protected:
const uint8_t* base_;
const uint8_t* start_;
template <typename T>
static constexpr T* alignTo_(T* p, size_t alignment) {
return (p + (alignment - 1)) & ~alignment;
}
static constexpr uint32_t alignSize_(uint32_t offset,
uint32_t alignment) {
return (offset + (alignment - 1)) & ~alignment;
}
static constexpr uint32_t pad_(uint32_t offset, uint32_t alignment) {
return (alignment - 1) - ((offset - 1) & (alignment - 1));
}
static int16_t searchForKey_(const uint8_t* keys, uint16_t n,
uint8_t k) const {
int16_t i = 0;
int16_t j = n; // Safe because n <= 256
while (i < j) {
int16_t k = (i + j) >> 1; // Safe because i,j in [0, 256]
if (keys[k] < k) {
i = k + 1;
} else if (k < keys[k]) {
j = k;
} else {
return i;
}
}
return -i - 1;
}
static int16_t searchForKeyAfter_(const uint8_t* keys, uint16_t n,
uint8_t k) const {
int16_t i = 0;
int16_t j = n; // Safe because n <= 256
while (i < j) {
int16_t k = (i + j) >> 1; // Safe because i,j in [0, 256]
if (keys[k] <= k) {
i = k + 1;
} else {
j = k;
}
}
return i;
}
template <typename Writer>
static size_t writePad_(Writer writer, size_t numWritten,
size_t alignment) {
static const uint8_t buffer[16] = { 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
const size_t nToPad = (-numWritten) & (alignment - 1);
size_t n = nToPad;
while (n) {
const size_t nToWrite = (n < sizeof(buffer)) ? n : sizeof(buffer);
writer(buffer, nToWrite);
n -= nToWrite;
}
return nToPad;
}
};
}
}
}
#endif
| true |
7fcc0c1ecd7059cf3f07525691297a5b879c26c8 | C++ | jmrCalvo/data-structure | /CLINVAR/include/enfermedad.h | UTF-8 | 3,920 | 3.4375 | 3 | [] | no_license | /**
@file TDA clinvar
**/
/*
* enfermedad.h
*
* Copyright (C) Juan F. Huete y Carlos Cano
*/
//**********************************************************************************************//
//**************Jose Manuel Rodríguez Calvo****************************************************//
//********************************************************************************************//
#ifndef __ENFERMEDAD_H
#define __ENFERMEDAD_H
#include <string>
#include <cstring>
#include <iostream>
using namespace std;
//! Clase enfermedad, asociada al TDA enfermedad
/*! enfermedad::enfermedad, .....
* Descripción contiene toda la información asociada a una enfermedad almacenada en la BD ClinVar-dbSNP (nombre de la enfermedad, id, BD que provee el id)
@todo Implementa esta clase, junto con su documentación asociada
*/
class enfermedad {
private:
string name; // nombre de la enfermedad. Almacenar completo en minúscula.
string ID; // ID único para la enfermedad
string database; // Base de datos que provee el ID
public:
/**
@brief constructor por defecto
**/
enfermedad(); //Constructor de enfermedad por defecto
/**
@brief construye una enfermedad
@param name: el nuevo nombre de la enfermedad
@param ID: el nuevo ID de la enfermedad
@param database: el nuevo database de la enfermedad
**/
enfermedad(const string & name, const string & ID, const string & database);
/**
@brief Modifica el nombre de la enfermdad
@param name: el nuevo nombre de la enfermedad
**/
void setName(const string & name);
/**
@brief Modifica el ID de la enfermdad
@param ID: el nuevo ID de la enfermedad
**/
void setID(const string & ID);
/**
@brief Modifica la database de la enfermdad
@param database: el nuevo database de la enfermedad
**/
void setDatabase(const string & database);
/**
@brief Devuelve el nombre de la enfermedad
@return nombre de la enfermedad
**/
string getName( ) const;
/**
@brief Devuelve el ID de la enfermedad
@return ID de la enfermedad
**/
string getID( ) const;
/**
@brief Devuelve el Database de la enfermedad
@return database de la enfermedad
**/
string getDatabase( ) const;
/**
@brief Se asigna una enfermedad
@param e: la enfermedad que se asigna
@return una referencia a la enfermdad
**/
enfermedad & operator=(const enfermedad & e);
/**
@brief Convierte una enfermedad a string
@return string de la enfermedad
**/
string toString() const;
/**
@brief Sobrecarga del operador == para ver si es igual
@param e: la enfermedad que se compara
@return true si es igual y false si es diferente
**/
// Operadores relacionales
bool operator==(const enfermedad & e) const;
/**
@brief Sobrecarga del operador != para ver si es diferente
@param e: la enfermedad que se compara
@return true si es diferente y false si es igual
**/
bool operator!=(const enfermedad & e) const;
/**
@brief Sobrecarga del operador < para ver si es diferente
@param e: la enfermedad que se compara
@return true si el nombre es menor y false si es mayor
**/
bool operator<(const enfermedad & e) const; //Orden alfabético por campo name.
/**
@brief Comprueba si el string que le pasa esta contenido
@param str: el string que hay que buscar
@return true si esta contenido
**/
bool operator>(const enfermedad & e) const;
bool nameContains(const string & str) const; //Devuelve True si str está incluido en el nombre de la enfermedad, aunque no se trate del nombre completo. No debe ser sensible a mayúsculas/minúsculas.
};
/**
@brief sobrecarga el operador de salida
@param os: el ostream sobre el que mostra la enfermedad
@param e: enfermedad que se va a mostrar
@return ostream del archivo ya volcado
**/
ostream& operator<< ( ostream& os, const enfermedad & e); //imprime enfermedad (con TODOS sus campos)
#endif
| true |
2355e932c1ec38a3a4e878e44401ae9ef5330001 | C++ | franhermani/argentum-taller | /client/sdl/exception.h | UTF-8 | 608 | 2.875 | 3 | [] | no_license | #ifndef SDL_EXCEPTION_H
#define SDL_EXCEPTION_H
#include <string>
#include <exception>
class SDLException : public std::exception {
std::string message;
public:
// Constructor
SDLException(const char *message, const char *sdl_error);
// Devuelve el mensaje de error
const char * what() const noexcept;
};
class SurfaceExistanceException : public std::exception {
std::string message;
public:
// Constructor
explicit SurfaceExistanceException(const char *message);
// Devuelve el mensaje de error
const char * what() const noexcept;
};
#endif // SDL_EXCEPTION_H
| true |
b60080148b0b979a6fc6ad853249549ada388a3b | C++ | bz866/Baruch-C-Certificate-HWs | /Level 6/Section 4.2b/Exercise 6/Stack.cpp | UTF-8 | 1,429 | 3.4375 | 3 | [] | no_license | #ifndef Stack_CPP
#define Stack_CPP
#include "Stack.hpp"
template <typename T, int size>
Stack<T, size>::Stack() : m_current(0), m_data(Array<T>(size)) {}
// template <typename T> // replaced by using an int value as template variable
// Stack<T, size>::Stack(int theSize) : m_current(theSize), m_data(Array<T>(theSize)) {}
template <typename T, int size>
Stack<T, size>::Stack(const Stack<T, size>& source) : m_current(source.m_current), m_data(source.m_data) {
// data container will call the copy constructor of the Array
}
template <typename T, int size>
Stack<T, size>::~Stack() {}
template <typename T, int size>
Stack<T, size>& Stack<T, size>::operator = (const Stack<T, size>& source) {
if (this != &source) {
delete m_data;
m_current = source.m_current;
m_data = source.m_data; // call the copy constructor of the Array
}
return *this;
}
template <typename T, int size>
void Stack<T, size>::Push(const T& val) {
try {
m_data[m_current] = val;
++m_current;
} // m_current will not get increment if indicing is not succeed
catch (ArrayException &arrEx) {
throw StackFullException();
}
}
template <typename T, int size>
T& Stack<T, size>::Pop() {
try {
T val2Return = m_data[m_current - 1]; // if invalid index then catch exception
--m_current;
return m_data[m_current]; // otherwise return element on top
}
catch (ArrayException &arrEx) {
throw StackEmptyException();
}
}
#endif | true |
771ef9ecfb992341966164d80fde47c6c29eff58 | C++ | cuberite/cuberite | /src/Entities/Floater.h | UTF-8 | 1,041 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive |
#pragma once
#include "Entity.h"
// tolua_begin
class cFloater :
public cEntity
{
// tolua_end
using Super = cEntity;
public: // tolua_export
CLASS_PROTODEF(cFloater)
cFloater(Vector3d a_Pos, Vector3d a_Speed, UInt32 a_PlayerID, int a_CountDownTime);
virtual void SpawnOn(cClientHandle & a_Client) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
// tolua_begin
bool CanPickup(void) const { return m_CanPickupItem; }
UInt32 GetOwnerID(void) const { return m_PlayerID; }
UInt32 GetAttachedMobID(void) const { return m_AttachedMobID; }
Vector3d GetBitePos(void) const { return m_BitePos; }
// tolua_end
protected:
// Position
Vector3d m_ParticlePos;
// Position just before the floater gets pulled under by a fish
Vector3d m_BitePos;
// Bool needed to check if you can get a fish.
bool m_CanPickupItem;
// Countdown times
int m_PickupCountDown;
int m_CountDownTime;
// Entity IDs
UInt32 m_PlayerID;
UInt32 m_AttachedMobID;
} ; // tolua_export
| true |
9524f8c9482f3e9618a4ec1e5d9278dfcc9864d8 | C++ | Faton6/containers_ADT | /new_own_classes/main_new_integer.cpp | UTF-8 | 2,116 | 2.90625 | 3 | [] | no_license | #include <stdexcept>
#include <iostream>
#include <string>
#include <cstdint>
//#include "integer.h"
#include "new_integer.cpp"
int main()
{
Integer a(12345);
std::cout << "################################\n";
Integer b("100000000000000000");
std::cout << "b = " << b << '\n';
Integer c;
c = a + b;
std::cout << "a + b = " << c << '\n';
c = a - b;
std::cout << "a - b = " << c << '\n';
a += b;
std::cout << "a += b\t a = " << a << '\n';
a -= b;
std::cout << "a -= b\t a = " << a << '\n';
a *= b;
std::cout << "a *= b\t a = " << a << '\n';
a = 100;
b /= a;
std::cout << "b /= a\t a = 100, b = " << b << '\n';
std::cout << "################################\n";
std::cout << "a == b : " << std::boolalpha << (a == b) << '\n';
std::cout << "a != b : " << std::boolalpha << (a != b) << '\n';
std::cout << "a >= b : " << std::boolalpha << (a >= b) << '\n';
std::cout << "a <= b : " << std::boolalpha << (a <= b) << '\n';
std::cout << "a > b : " << std::boolalpha << (a > b) << '\n';
std::cout << "a < b : " << std::boolalpha << (a < b) << '\n';
std::cout << "################################\n";
Integer test("123456");
std::cout << "test = "<< test << '\n';
std::cout << "\n################################\n\n";
test.set_num_str("1111111111");
std::cout << " set_num_str : "<< test << '\n';
++test;
std::cout << "++test = "<< test << '\n';
--test;
std::cout << "--test = "<< test << '\n';
test++;
std::cout << "test++ = "<< test << '\n';
test--;
std::cout << "test-- = "<< test << '\n';
//std::cout << "################################\n";
//std::cout << "test = " << (number) << '\n';
/*
int64_t a = 120, b = 7, c = 1;
c = a + b;
std::cout << "a + b = " << c << '\n';
c = a - b;
std::cout << "a - b = " << c << '\n';
c = a * b;
std::cout << "a * b = " << c << '\n';
c = a % b;
std::cout << "a % b = " << c << '\n';
c = a / b;
std::cout << "a / b = " << c << '\n';
*/
}
| true |
366ab4ac1e11872bc693d280e4d93a9c16b6f85e | C++ | mbatc/atLib | /projects/atLib/source/Graphics/API/Interface/atRenderTarget.cpp | UTF-8 | 728 | 2.828125 | 3 | [
"MIT",
"LicenseRef-scancode-public-domain"
] | permissive | #include "atRenderTarget.h"
void atRenderTarget::AttachColour(atTexture *pTexture, const int64_t &slot, const int64_t &layer)
{
DetachColour(slot);
Attachment att;
att.pTex = pTexture;
att.slot = slot;
att.mipLayer = layer;
m_color.push_back(att);
}
void atRenderTarget::AttachDepth(atTexture *pTexture)
{
DetachDepth();
m_depth.pTex = pTexture;
m_depth.slot = 0;
m_depth.mipLayer = 0;
}
void atRenderTarget::DetachColour(const int64_t &slot)
{
for (int64_t i = 0; i < m_color.size(); ++i)
if (m_color[i].slot == slot)
m_color.erase(i);
}
void atRenderTarget::DetachDepth()
{
m_depth = Attachment();
}
bool atRenderTarget::Clear(const atVec4F &color, const float &depth) { return false; }
| true |
fda494fd499cdfb227a11836a0e835fc0323d84a | C++ | DeviNoles/Matrix-Manipulation-Utility | /src/matman.cpp | UTF-8 | 17,240 | 3.140625 | 3 | [] | no_license | /**
* File: matman.cpp
* Description: Simple matrix manipulation utility.
* Provides an interactive interface in which users have a variety
* of commands that manipulate matrices. Nothing too complicated.
* Author: Forgetful Employee
* Date: 2017-02-21
*/
#include <iomanip> /* setw */
#include <iostream> /* cin, cout */
#include <utility> /* pair */
#include <string> /* string */
#include <fstream>
#include "matrix.hpp"
/* CONSTANTS & TYPEDEFS --------------------------------------------------- */
/* Menu options. */
const char ADD_MATRIX_TO_LIST = 'a';
const char REMOVE_MATRIX_FROM_LIST = 'r';
const char PGM_MATRIX_TO_LIST = 'G';
const char DISPLAY_MATRIX = 'd';
const char ADD_MATRICES = 'A';
const char MULTIPLY_MATRIX_BY_SCALAR = 'S';
const char ROTATE_MATRIX = 'R';
const char BLUR_MATRIX = 'B';
const char EXPORT_TO_FILE = 'x';
const char MULTIPLY_ROW_BY_SCALAR = 'M';
const char ADD_SCALAR_ROW_TO_ROW = 'c';
const char DISPLAY_INFORMATION = 'i';
const char PRINT_MENU = 'p';
const char PRINT_MATRIX_LIST = 'P';
const char QUIT = 'q';
const unsigned MAX_STRLEN = 100000;
using MList = std::pair<std::string, Matrix>;
/* PROTOTYPES ------------------------------------------------------------- */
/* Printing. */
void DisplayMatrixList(const MList*);
void DisplayMatrix(const std::string&, const MList *);
void DisplayMenu();
void DisplayMatrixInformation(const std::string&, const MList *);
/* List manipulation. */
void AddMatrixToList(const std::string&, const Matrix&, MList * const);
void RemoveMatrixFromList(const std::string&, MList *);
/* Utility. */
bool NameExists(const std::string&, const MList *);
std::string NewMatrixName(const MList *);
std::string GetMatrixName(const MList *);
int IndexOfMatrix(const std::string&, const MList *);
unsigned GetValidRow(const std::string&, const MList *);
/* MAIN ------------------------------------------------------------------- */
int main () {
char choice;
int scalar;
int m1loc, m2loc;
Matrix resMatrix;
MList mlist[10];
std::string name, elements, rowElements, m1, m2;
unsigned rows, cols, r1, r2;
std::cout << "\n";
DisplayMenu();
/* Get user's choice. */
std::cout << "\n> ";
std::cin >> choice;
std::cin.ignore(MAX_STRLEN, '\n');
while (true)
{
std::cout << "\n";
switch (choice)
{
case ADD_MATRIX_TO_LIST: /* -------------------------------------- */
/* Get the matrix name. */
std::cout << "new matrix name: ";
name = NewMatrixName(mlist);
/* Get the number of rows of the matrix. */
std::cout << "number of rows: ";
std::cin >> rows;
std::cin.ignore(MAX_STRLEN, '\n');
/* Get the number of columns of the matrix. */
std::cout << "number of cols: ";
std::cin >> cols;
std::cin.ignore(MAX_STRLEN, '\n');
for (unsigned i = 0; i < rows; ++i)
{
/* Get the elements of the matrix. */
std::cout << "elements of row " << i+1 << ": ";
std::getline(std::cin, rowElements, '\n');
elements += " " + rowElements;
}
AddMatrixToList(name, Matrix(rows, cols, elements), mlist);
break;
case REMOVE_MATRIX_FROM_LIST: /* --------------------------------- */
/* Get the matrix name. */
std::cout << "matrix name: ";
name = GetMatrixName(mlist);
RemoveMatrixFromList(name, mlist);
break;
case DISPLAY_MATRIX: /* ------------------------------------------ */
/* Get the matrix name. */
std::cout << "matrix name: ";
name = GetMatrixName(mlist);
DisplayMatrix(name, mlist);
break;
case ADD_MATRICES: /* -------------------------------------------- */
// Get name for matrix denoting A + B.
std::cout << "new matrix name: ";
name = NewMatrixName(mlist);
// Matrix A.
std::cout << "m1: ";
m1 = GetMatrixName(mlist);
// Matrix B.
std::cout << "m2: ";
m2 = GetMatrixName(mlist);
m1loc = IndexOfMatrix(m1, mlist);
m2loc = IndexOfMatrix(m2, mlist);
resMatrix = mlist[m1loc].second + mlist[m2loc].second;
AddMatrixToList(name, resMatrix, mlist);
break;
case ROTATE_MATRIX: /* -------------------------------------------- */
/* Get name for rotated matrix. */
std::cout << "new matrix name: ";
name = NewMatrixName(mlist);
/* Matrix A. */
std::cout << "name of matrix to rotate: ";
m1 = GetMatrixName(mlist);
m1loc = IndexOfMatrix(m1, mlist);
resMatrix = Rotate90Clockwise(mlist[m1loc].second);
AddMatrixToList(name, resMatrix, mlist);
break;
case BLUR_MATRIX: /* -------------------------------------------- */
{
/* Get name for blurred matrix. */
std::cout << "new matrix name: ";
name = NewMatrixName(mlist);
/* Matrix A. */
std::cout << "name of matrix to blur: ";
m1 = GetMatrixName(mlist);
m1loc = IndexOfMatrix(m1, mlist);
//k-value
int k;
std::cout << "enter odd k-value: ";
std::cin >> k;
resMatrix = Blur(mlist[m1loc].second, k);
AddMatrixToList(name, resMatrix, mlist);
}
break;
case PGM_MATRIX_TO_LIST: /* -------------------------------------------- */
{
/* Get name for new matrix. */
std::cout << "new matrix name: ";
name = NewMatrixName(mlist);
//Get filename
std::string filename="";
std::cout << "name of pgm file (include extension): ";
std::cin >> filename;
Matrix m1(filename);
AddMatrixToList(name, m1, mlist);
}
break;
case EXPORT_TO_FILE: /* -------------------------------------------- */
{
std::string matrixName;
std::cout << "name of matix to export: ";
std::cin >> matrixName;
//Get filename
std::string filename;
std::cout << "name of export file (include extension): ";
std::cin >> filename;
m1loc = IndexOfMatrix(matrixName, mlist);
(mlist[m1loc].second).Save(filename);
std::cout << "Export complete." << "\n";
}
break;
case MULTIPLY_MATRIX_BY_SCALAR: /* -------------------------------------------- */
/* Get name for matrix denoting c * A. */
std::cout << "new matrix name: ";
name = NewMatrixName(mlist);
/* Matrix A. */
std::cout << "m1: ";
m1 = GetMatrixName(mlist);
/* Scalar c. */
std::cout << "c: ";
std::cin >> scalar;
std::cin.ignore(MAX_STRLEN, '\n');
m1loc = IndexOfMatrix(m1, mlist);
resMatrix = scalar * mlist[m1loc].second;
AddMatrixToList(name, resMatrix, mlist);
break;
case MULTIPLY_ROW_BY_SCALAR: /* -------------------------------------------- */
/* Get name of matrix. */
std::cout << "matrix name: ";
name = GetMatrixName(mlist);
/* R. */
std::cout << "r1: ";
r1 = GetValidRow(name, mlist);
/* Scalar. */
std::cout << "c: ";
std::cin >> scalar;
m1loc = IndexOfMatrix(name, mlist);
mlist[m1loc].second.MultRow(r1, scalar);
break;
case ADD_SCALAR_ROW_TO_ROW: /* -------------------------------------------- */
/* Get name of matrix. */
std::cout << "matrix name: ";
name = GetMatrixName(mlist);
/* Original row. */
std::cout << "r1: ";
r1 = GetValidRow(name, mlist);
/* Multiple row. */
std::cout << "r2: ";
r2 = GetValidRow(name, mlist);
while (r1 == r2)
{
std::cout << "invalid row index. cannot equal r1.\n";
std::cout << "re-enter: ";
r2 = GetValidRow(name, mlist);
}
/* Scalar. */
std::cout << "c: ";
std::cin >> scalar;
m1loc = IndexOfMatrix(name, mlist);
mlist[m1loc].second.AddRow(r1, r2, scalar);
break;
case DISPLAY_INFORMATION: /* -------------------------------------------- */
/* Get name of matrix. */
std::cout << "matrix name: ";
name = GetMatrixName(mlist);
DisplayMatrixInformation(name, mlist);
break;
case PRINT_MENU: /* -------------------------------------------- */
DisplayMenu();
break;
case PRINT_MATRIX_LIST: /* -------------------------------------------- */
DisplayMatrixList(mlist);
break;
case QUIT: /* -------------------------------------------- */
break;
default: /* -------------------------------------------- */
std::cout << "invalid menu choice.\n";
break;
}
if (choice == QUIT)
break;
/* Get user's choice. */
std::cout << "\n> ";
std::cin >> choice;
std::cin.ignore(MAX_STRLEN, '\n');
}
return 0;
}
/*****************************************************************************
* DisplayMatrixList - Prints out the list of matrices. Just the names,
* not the entire matrices.
*
* Assumptions: No element of the matrix has 6 digits to the left of the
* decimal point.
*/
void DisplayMatrixList (const MList* mlist)
{
std::cout << std::left;
/* Unicode symbols for the nice boundaries. */
const std::string HORI_BAR = u8"\u2500";
const std::string VERT_BAR = u8"\u2502";
const std::string TOP_CROSS_BAR = u8"\u252c";
const std::string BOTTOM_CROSS_BAR = u8"\u2534";
const std::string CORNER_TOP_LEFT = u8"\u250c";
const std::string CORNER_TOP_RIGHT = u8"\u2510";
const std::string CORNER_BOTTOM_LEFT = u8"\u2514";
const std::string CORNER_BOTTOM_RIGHT = u8"\u2518";
/* Print the top border. */
std::cout << CORNER_TOP_LEFT;
for (unsigned i = 0; i < 10; ++i)
{
std::cout << HORI_BAR << TOP_CROSS_BAR << HORI_BAR << HORI_BAR
<< HORI_BAR << HORI_BAR;
if (i != 9)
std::cout << TOP_CROSS_BAR;
}
std::cout << CORNER_TOP_RIGHT << "\n";
/* Print the list of matrices. */
std::cout << VERT_BAR;
for (unsigned i = 0; i < 10; ++i)
{
std::cout << i << VERT_BAR << " " << std::setw(2)
<< mlist[i].first << " " << VERT_BAR;
}
/* Print the bottom border. */
std::cout << "\n" << CORNER_BOTTOM_LEFT;
for (unsigned i = 0; i < 10; ++i)
{
std::cout << HORI_BAR << BOTTOM_CROSS_BAR << HORI_BAR << HORI_BAR
<< HORI_BAR << HORI_BAR;
if (i != 9)
std::cout << BOTTOM_CROSS_BAR;
}
std::cout << CORNER_BOTTOM_RIGHT << "\n";
}
/*****************************************************************************
* DisplayMenu - Prints out the program menu.
*/
void DisplayMenu()
{
std::cout << ADD_MATRIX_TO_LIST << ": add matrix to list (manually)\n"
<< PGM_MATRIX_TO_LIST << ": add matrix to list (from pgm file)\n"
<< REMOVE_MATRIX_FROM_LIST << ": remove matrix from list\n"
<< DISPLAY_MATRIX << ": display matrix\n"
<< ADD_MATRICES << ": add matrices\n"
<< MULTIPLY_MATRIX_BY_SCALAR << ": multiply matrix by a scalar\n"
<< ROTATE_MATRIX << ": rotate a matrix 90 degrees clockwise\n"
<< BLUR_MATRIX << ": blur a matrix\n"
<< MULTIPLY_ROW_BY_SCALAR << ": multiply a row of a matrix by a "
<< "scalar\n"
<< ADD_SCALAR_ROW_TO_ROW << ": add a scalar multiple of a row to "
<< "another row of a matrix\n"
<< DISPLAY_INFORMATION << ": matrix information\n"
<< PRINT_MENU << ": print this menu\n"
<< PRINT_MATRIX_LIST << ": print matrix list\n"
<< EXPORT_TO_FILE << ": export matrix to file\n"
<< QUIT << ": quit\n";
}
/*****************************************************************************
* AddMatrixToList - Adds a matrix to the list of matrices.
* Puts the matrix in the first empty spot in the list.
* If there is no empty spot, nothing happens.
*/
void AddMatrixToList(const std::string& name, const Matrix& M,
MList * const mlist)
{
for (unsigned i = 0; i < 10; ++i)
{
if (mlist[i].first == "")
{
mlist[i].first = name;
mlist[i].second = M;
break;
}
}
}
/*****************************************************************************
* NameExists - Checks to see if a matrix with the name 'name' exists in
* the list of matrices.
*/
bool NameExists(const std::string& name, const MList * mlist)
{
int mloc = IndexOfMatrix(name, mlist);
if (mloc != -1)
return true;
return false;
}
/*****************************************************************************
* RemoveMatrixFromList - Looks through the list of matrices for a matrix
* with name 'name' and removes it from the list.
* If the 'name' isn't found, nothing happens.
*/
void RemoveMatrixFromList(const std::string& name, MList * const mlist)
{
int mloc = IndexOfMatrix(name, mlist);
mlist[mloc].first = "";
mlist[mloc].second = Matrix();
}
/*****************************************************************************
* DisplayMatrix - Prints out the matrix with name 'name' from the list
* of matrices.
*/
void DisplayMatrix(const std::string& name, const MList * mlist)
{
int mloc = IndexOfMatrix(name, mlist);
std::cout << mlist[mloc].second;
}
/*****************************************************************************
* NewMatrixName - Generates a new matrix name that can be put into the list
* of matrices without causing any name conflicts.
*/
std::string NewMatrixName(const MList * mlist)
{
std::string name;
/* Get the desired matrix name. */
std::cin >> name;
std::cin.ignore(MAX_STRLEN, '\n');
/* Ensure a matrix with said name does not exist. */
while ( (name.length() < 1) || (name.length() > 2)
|| NameExists(name, mlist) )
{
std::cout << "invalid name. name cannot exist and can only "
<< "have 1 or 2 characters.\n"
<< "re-enter: ";
std::cin >> name;
std::cin.ignore(MAX_STRLEN, '\n');
}
return name;
}
/*****************************************************************************
* GetMatrixName - Returns the name of a matrix in the list.
*/
std::string GetMatrixName(const MList * mlist)
{
std::string name;
/* Get the desired matrix name. */
std::cin >> name;
std::cin.ignore(MAX_STRLEN, '\n');
/* Ensure a matrix with said name exists. */
while ( !NameExists(name, mlist) )
{
std::cout << "invalid name. name must exist.\n";
std::cout << "re-enter: ";
std::cin >> name;
std::cin.ignore(MAX_STRLEN, '\n');
}
return name;
}
/*****************************************************************************
* GetValidRow - Ensures that only valid indices of matrix with name 'name'
* are returned.
*/
unsigned GetValidRow(const std::string& name, const MList * mlist)
{
int mloc = IndexOfMatrix(name, mlist);
unsigned rowIndex;
/* Get the desired row index. */
std::cin >> rowIndex;
std::cin.ignore(MAX_STRLEN, '\n');
/* Ensure the row is valid for the given matrix. */
while (rowIndex < 1 || rowIndex > mlist[mloc].second.NumRows())
{
std::cout << "invalid row index. index must exist.\n";
std::cout << "re-enter: ";
std::cin >> rowIndex;
std::cin.ignore(MAX_STRLEN, '\n');
}
return rowIndex;
}
/*****************************************************************************
* DisplayMatrixInformation - Prints out useful information about the matrix
* with name 'name'.
*/
void DisplayMatrixInformation(const std::string& name, const MList * mlist)
{
int mloc = IndexOfMatrix(name, mlist);
std::cout << "Size: " << mlist[mloc].second.Size() << "\n";
}
/*****************************************************************************
* IndexOfMatrix - Returns the index of the matrix with name 'name' in the
* list of matrices.
*/
int IndexOfMatrix(const std::string& name, const MList * mlist)
{
int mloc = -1;
for (unsigned i = 0; i < 10; ++i)
if (name == mlist[i].first)
mloc = i;
return mloc;
}
| true |
562e03822be59f88f3bbb83cdd885e6d6a005e2e | C++ | UnknownFreak/OneFlower | /Project/Object/IBaseComponent.hpp | UTF-8 | 1,098 | 2.71875 | 3 | [] | no_license | #ifndef IBaseComponent_HPP
#define IBaseComponent_HPP
#include "BaseComponent.hpp"
#include <Helpers/String.hpp>
#include <Helpers/Enum/ComponentType.hpp>
#include <Module/EngineModuleManager.hpp>
#include <Module/Logger/OneLogger.hpp>
namespace Component
{
template<typename>
class IBase : public Base
{
public:
virtual ~IBase() = default;
Enums::ComponentType getType() const
{
return typeID;
}
Core::String getTypeName() const
{
return componentName;
}
Base* copy() const {
Engine::GetModule<EngineModule::Logger::OneLogger>().getLogger("Component::IBase").Error("Component: " + getTypeName() + " is missing copy() override, it will always return nullptr");
return nullptr;
}
std::unique_ptr<Base> ucopy() const
{
Engine::GetModule<EngineModule::Logger::OneLogger>().getLogger("Component::IBase").Error("Component: " + getTypeName() + " is missing ucopy() override, it will always return empty unique_ptr");
return nullptr;
}
static Core::String componentName;
static Enums::ComponentType typeID;
protected:
private:
};
}
#endif | true |
c28b5afdba9c0fbf16bdf14b9ff76ec152a4a751 | C++ | QuentinVecchio/ModelisationProject | /Client/Fonctions.h | UTF-8 | 1,308 | 3.28125 | 3 | [] | no_license | #pragma once
#include <vector>
#include "Etiquette.h"
using namespace std;
string enleveEspace(const string &s) {
string newS;
for (int i = 0; i < s.length(); i++) {
if (s[i] != ' ') {
newS += s[i];
}
}
return newS;
}
vector<string>* splitString(const string &chaine, const char &separateur) {
vector<string> *strings = new vector<string>();
string newChaine = "";
for (int i = 0; i < chaine.length(); i++) {
if (chaine[i] != separateur) {
newChaine += chaine[i];
}
else {
if (enleveEspace(newChaine) != "") {
strings->push_back(newChaine);
}
newChaine = "";
}
}
if (enleveEspace(newChaine) != "") {
strings->push_back(newChaine);
}
return strings;
}
string extraitStringDansIntervalle(const string &s, const int &borneInf, const int &borneSup) {
string newS;
for (int i = borneInf; i < borneSup; i++)
newS += s[i];
return newS;
}
bool contient(const string &chaine, const string &motCherche) {
std::size_t found = chaine.find(motCherche);
if (found != std::string::npos)
return true;
else
return false;
}
bool isInVector(vector<Etiquette *>* ensemble, Etiquette * valeur) {
for (int i = 0; i<ensemble->size(); i++) {
if (ensemble->at(i) == valeur)
return true;
}
return false;
}
| true |
920812cc08325c062504961827d506e4bc6ff9ef | C++ | KimPopsong/Embedded_Systems_Class | /Test.cpp | UTF-8 | 2,819 | 2.609375 | 3 | [] | no_license | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define LCD_D4 2
#define LCD_D5 3
#define LCD_D6 1
#define LCD_D7 4
#define LCD_RS 7
#define LCD_EN 0
#define BT0 23
#define BT1 12
#define BT2 13
#define BT3 10
#define BT4 14
#define BT5 21
#define BT6 11
#define BT7 22
#define BT8 26
#define BT9 27
#define EQL 24
#define PLUS 5
#define MINUS 6
int sum = 0, temp = 0;
int count = 0;
int tmpcnt = 0;
char tmp[40] = { 0 };
int opflag = 1;
char frontop = 0;
int minusflag = 0;
void Print(char c)
{
printf("%c", c);
}
void Input(char c)
{
int i;
char Inval[20] = "InvalidOperation";
if (c == '+' || c == '-') //when input is + or -
{
if ((minusflag == 0) && (c == '-')) //start as -
{
opflag = 1;
minusflag = 1;
frontop = '-';
}
else if (opflag) //start as + or double operation
{
printf("Error\n");
return;
}
else //Normal
{
opflag = 1;
minusflag = 1;
for (i = 0; i < tmpcnt; i++) //make string to int
{
temp += (tmp[i] - 48) * pow(10, (tmpcnt - i - 1));
}
if (frontop == '+')
{
sum += temp;
temp = 0;
}
else if (frontop == '-')
{
sum -= temp;
temp = 0;
}
else
{
sum += temp;
temp = 0;
}
tmpcnt = 0;
frontop = c;
}
Print(c);
}
else if (c == '=') //=
{
if (opflag) //start as = or double operation
{
printf("Error\n");
return;
}
else //Normal
{
Print(c);
opflag = 1;
for (i = 0; i < tmpcnt; i++) //make string to int
{
temp += (tmp[i] - 48) * pow(10, (tmpcnt - i - 1));
}
if (frontop == '+')
{
sum += temp;
temp = 0;
}
else if (frontop == '-')
{
sum -= temp;
temp = 0;
}
else //no front operation
{
printf("Error\n");
return;
}
tmpcnt = 0;
if (sum < 0)
{
Print('-');
sum *= -1;
}
while (sum != 0)
{
tmp[tmpcnt] = (sum % 10) + 48;
tmpcnt++;
sum /= 10;
}
tmpcnt--;
for (; tmpcnt >= 0; tmpcnt--)
{
Print(tmp[tmpcnt]);
}
count = 0;
}
}
else //number
{
Print(c);
tmp[tmpcnt] = c;
tmpcnt++;
opflag = 0;
minusflag = 1;
}
}
int main(int argc, char** argv)
{
while (1)
{
char c;
scanf(" %c", &c);
if (c == '0')
{
Input('0');
}
else if (c == '1')
{
Input('1');
}
else if (c == '2')
{
Input('2');
}
else if (c == '3')
{
Input('3');
}
else if (c == '4')
{
Input('4');
}
else if (c == '5')
{
Input('5');
}
else if (c == '6')
{
Input('6');
}
else if (c == '7')
{
Input('7');
}
else if (c == '8')
{
Input('8');
}
else if (c == '9')
{
Input('9');
}
else if (c == '=')
{
Input('=');
}
else if (c == '+')
{
Input('+');
}
else if (c == '-')
{
Input('-');
}
}
} | true |
caff57c6b42cf5a12fb9f7fd6ad846ecb24285e8 | C++ | johnsebin97/Google_Kickstart-2020 | /Round B/bike_tour/Solution.cpp | UTF-8 | 562 | 3 | 3 | [] | no_license | #include <iostream>
using namespace std;
int solve() {
int H[3];
int N, c, p, pp, result = 0;
cin >> N;
for (auto i = 0; i < N; i++)
{
c = i%3;
cin >> H[c];
if (1 < i && H[pp] < H[p] && H[p] > H[c]) {
result++;
}
pp = p;
p = c;
}
return result;
}
int main(int argc, char const *argv[])
{
int T;
cin >> T;
for (auto x = 1; x <= T; x++)
{
auto y = solve();
cout << "Case #" << x << ": " << y << endl;
}
return 0;
}
| true |
5f4a5329f94d5add9d37647c618ecca6f0a48234 | C++ | davidjacobo/Competencias | /HackerRank/pairs.cpp | UTF-8 | 665 | 3.0625 | 3 | [] | no_license | #include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
void capture(vector<int>& arr,set<int>& st,int& n,int& k) {
int t;
cin>>n>>k;
for(int i=0;i<n;++i) {
cin>>t;
arr.push_back(t);
st.insert(t);
}
sort(arr.begin(), arr.end());
}
int solve(const vector<int> arr,const set<int> st,int k) {
int ans = 0;
for(auto x:arr) {
int other = x - k;
if(st.find(other)!=st.end()) {
++ans;
}
}
return ans;
}
int main() {
vector<int> arr;
set<int> st;
int n,k;
capture(arr,st,n,k);
cout<<solve(arr, st, k)<<endl;
} | true |
54eb4675ad73a46e8573f29d1d21d56dc8640cee | C++ | Nanored4498/ACM-L3 | /TD7-ycoudert/ycoudert-821.cpp | UTF-8 | 888 | 2.609375 | 3 | [] | no_license | #include <iostream>
#include <vector>
#include<iomanip>
using namespace std;
int main() {
cout.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(3);
int m[101][101];
bool u[101];
vector<int> s;
int i, j, a, b, c;
double res;
while(cin >> a >> b) {
if(a == 0) return 0;
s.clear();
for(i = 1; i < 101; i++) {
u[i] = false;
for(j = 1; j < 101; j++)
if(j == i) m[i][j] = 0;
else m[i][j] = 101;
}
do {
u[a] = u[b] = true;
m[a][b] = 1;
cin >> a >> b;
} while(a > 0);
for(i = 1; i < 101; i++) if(u[i]) s.push_back(i);
for(int k : s)
for(int i : s)
for(int j : s)
m[i][j] = min(m[i][j], m[i][k]+m[k][j]);
res = 0;
a = s.size();
for(int i : s)
for(int j : s)
if(i != j) res += m[i][j];
cout << "Case " << (++c) << ": average length between pages = " << res / (a-1) / a << " clicks\n";
}
} | true |
4d4b8b4c6a9426048485c1d6e1d4cb6b57e24af3 | C++ | yasserelsaid/PaintForKids | /Actions/AddTriAction.cpp | UTF-8 | 1,476 | 2.890625 | 3 | [] | no_license | #include "AddTriAction.h"
#include "..\ApplicationManager.h"
#include "..\GUI\input.h"
#include "..\GUI\Output.h"
AddTriAction::AddTriAction(ApplicationManager * pApp):Action(pApp)
{}
void AddTriAction::ReadActionParameters()
{
//Get a Pointer to the Input / Output Interfaces
Output* pOut = pManager->GetOutput();
Input* pIn = pManager->GetInput();
pOut->PrintMessage("New Triangle: Click at first corner");
//Read 1st corner and store in point P1
pIn->GetPointClicked(P1.x, P1.y);
pOut->PrintMessage("New Triangle: Click at second corner");
//Read 2nd corner and store in point P2
pIn->GetPointClicked(P2.x, P2.y);
pOut->PrintMessage("New Triangle: Click at Third corner");
//Read 3nd corner and store in point P3
pIn->GetPointClicked(P3.x, P3.y);
RectGfxInfo.isFilled = UI.FillFigures; //default is not filled
//get drawing, filling colors and pen width from the interface
RectGfxInfo.DrawClr = pOut->getCrntDrawColor();
RectGfxInfo.FillClr = pOut->getCrntFillColor();
pOut->ClearStatusBar();
}
//Execute the action
void AddTriAction::Execute()
{
//This action needs to read some parameters first
ReadActionParameters();
Output* pOut = pManager->GetOutput();
//Create a rectangle with the parameters read from the user
CTriangle *T=new CTriangle(P1,P2,P3, RectGfxInfo);
//Add the rectangle to the list of figures
if(T->IsValid())
pManager->AddFigure(T);
else
pOut->PrintMessage("Invalid points for drawing triangle.");
}
| true |
f3aa6d13d10b08ef0c4c23632cd10a743ecc7e6b | C++ | nedma/ShaderX | /X3/Section 4 - Image Space/4.6 Aras Pranckevicius/sourcecode/dingus/dingus/utils/Singleton.h | UTF-8 | 1,145 | 2.90625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | // --------------------------------------------------------------------------
// Dingus project - a collection of subsystems for game/graphics applications
// --------------------------------------------------------------------------
#ifndef __SINGLETON_H
#define __SINGLETON_H
namespace dingus {
template<typename T>
class CSingleton {
public:
static T& getInstance() {
if( !isCreated() )
mSingleInstance = T::createInstance();
return *mSingleInstance;
}
static void finalize() {
if( !isCreated() )
return;
T::deleteInstance( *mSingleInstance );
mSingleInstance = 0;
}
protected:
static void assignInstance( T& instance ) { mSingleInstance = &instance; }
static bool isCreated() { return ( mSingleInstance != NULL ); }
CSingleton() { }
private:
static T* mSingleInstance;
};
template< typename T >
T* CSingleton<T>::mSingleInstance = 0;
#define IMPLEMENT_SIMPLE_SINGLETON(clazz) \
static clazz* createInstance() { return new clazz(); } \
static void deleteInstance( clazz& o ) { delete &o; } \
friend class dingus::CSingleton<clazz>
}; // namespace
#endif
| true |
da5a9fac658ed76c0f5812830a7ab2b3cf200bf3 | C++ | felipesdias/Extractor-URI-Online-Judge | /URI-ES/PRINCIPIANTE/2029 - Honey Reservoir.cpp | UTF-8 | 455 | 2.65625 | 3 | [] | no_license | // Autor: Felipe Souza Dias <felipe.s.dias@outlook.com>
// Nome: Honey Reservoir
// Nível: %d
// Categoria: PRINCIPIANTE
// URL: https://www.urionlinejudge.com.br/judge/es/problems/view/2029
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
double n, d;
while(cin >> n >> d) {
cout << fixed << setprecision(2) << "ALTURA = " << n/(d*d*3.14/4) << endl;
cout << "AREA = " << d*d*3.14/4 << endl;
}
return 0;
}
| true |
1921a3f6777aacb0e88f24c311a1897ab788eb4b | C++ | advatrix/labs3sem | /astroid/astroidProg/Astroid.cpp | UTF-8 | 892 | 3.109375 | 3 | [] | no_license | #include <strstream>
#include "Astroid.h"
namespace astroid {
Astroid::Astroid() {
r = 1;
Ra = 4;
}
double Astroid::length(double t) const {
if (t > acos(-1) * 2) return length();
if (t < 0) return 0;
if (t < (acos(-1))/2) return 1.5 * Ra * sin(t) * sin(t);
if (t < acos(-1)) return length() / 4 + length(t - (acos(-1))/2);
if (t < 3 * acos(-1) / 2) return length() / 2 + length(t - acos(-1));
return length() * 3 / 4 + length(t - 3 * acos(-1) / 2);
}
Astroid::Astroid(double p) {
if (p < 0) throw std::exception("invalid radius");
r = p;
Ra = 4 * p;
}
Astroid& Astroid::set(double p) {
if (p < 0) throw std::exception("invalid radius");
r = p;
Ra = 4 * p;
return *this;
}
Point Astroid::y(double x) {
if (x > Ra || x < -Ra) throw std::exception("illegal x");
double y = Ra * pow(1 - (pow(x / Ra, 2. / 3)), 3. / 2);
return { y, -y };
}
}
| true |
c6b76a9179d274abea557019fb781cd3dd6abd82 | C++ | btcup/sb-admin | /exams/2558/02204111/1/midterm/3_1_715_5620500764.cpp | UTF-8 | 1,699 | 3.0625 | 3 | [
"MIT"
] | permissive | #include <iostream>
using namespace std;
int main()
{
int b,c;
char a;
cout<<"Are you member (Y or N) : ";
cin>>a;
if(a=='Y')
{
cout<<"How old are you? :";
cin>>b;
if(b<2)
{
cout<<"Normal price : ";
cin>>c;
c=c*0;
cout<<"You have to pay "<<c<<endl;
}
else if(b>=2&&b<=12)
{
cout<<"Normal price : ";
cin>>c;
c=c*30/100;
cout<<"You have to pay "<<c<<endl;
}
else if(b>12)
{
cout<<"Normal price : ";
cin>>c;
c=c/2;
cout<<"You have to pay "<<c<<endl;
}
}
else if(a=='N')
{
cout<<"How old are you? :";
cin>>b;
if(b<2)
{
cout<<"Normal price : ";
cin>>c;
c=c/0;
cout<<"You have to pay "<<c<<endl;
}
else if(b>=2&&b<=10)
{
cout<<"Normal price : ";
cin>>c;
c=c/2;
cout<<"You have to pay "<<c<<endl;
}
else if(b>10)
{
cout<<"Normal price : ";
cin>>c;
cout<<"You have to pay "<<c<<endl;
}
}
system("pause");
return 0;
}
| true |
1ebb03cb55645194bbef3df7e1e729a8a6d33f91 | C++ | kunal164107/GfG | /Tree/BinaryTree/Find n-th node of inorder traversal.cpp | UTF-8 | 806 | 3.671875 | 4 | [] | no_license | #include <iostream>
#include <queue>
using namespace std;
class node{
public:
int data;
node* left;
node* right;
};
node* getnewnode(int key){
node* newnode = new node();
newnode->data = key;
newnode->left = NULL;
newnode->right = NULL;
return newnode;
}
void inorder(node* root,int n);
int main(){
node* root = NULL;
root = getnewnode(7);
root->left = getnewnode(2);
root->right = getnewnode(3);
root->right->left = getnewnode(4*2);
root->right->right = getnewnode(5);
// root->right->left = getnewnode(60);
// root->right->right = getnewnode(70);
inorder(root,3);
return 0;
}
int count=0;
void inorder(node* root,int n){
if(root==NULL) return;
inorder(root->left,n);
count++;
if(count==n){
cout<<root->data<<endl;
return;
}
inorder(root->right,n);
} | true |
e0fe649f88fe96e430266b2260bcd2281266d0fa | C++ | wwwgitcom/CORA | /Cora/TOnce.h | UTF-8 | 71,006 | 2.609375 | 3 | [] | no_license | #pragma once
template<typename T1>
__forceinline void ONCE(T1 &&t1)
{
t1();
}
template<typename T1, typename T2>
__forceinline void ONCE(T1 &&t1, T2 &&t2)
{
t1();
t2();
}
template<typename T1, typename T2, typename T3>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3)
{
t1();
t2();
t3();
}
template<typename T1, typename T2, typename T3, typename T4>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4)
{
t1();
t2();
t3();
t4();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5)
{
t1();
t2();
t3();
t4();
t5();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6)
{
t1();
t2();
t3();
t4();
t5();
t6();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47, typename T48>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47, T48 &&t48)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
t48();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47, typename T48, typename T49>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47, T48 &&t48, T49 &&t49)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
t48();
t49();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47, typename T48, typename T49, typename T50>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47, T48 &&t48, T49 &&t49, T50 &&t50)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
t48();
t49();
t50();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47, typename T48, typename T49, typename T50, typename T51>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47, T48 &&t48, T49 &&t49, T50 &&t50, T51 &&t51)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
t48();
t49();
t50();
t51();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47, typename T48, typename T49, typename T50, typename T51, typename T52>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47, T48 &&t48, T49 &&t49, T50 &&t50, T51 &&t51, T52 &&t52)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
t48();
t49();
t50();
t51();
t52();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47, typename T48, typename T49, typename T50, typename T51, typename T52, typename T53>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47, T48 &&t48, T49 &&t49, T50 &&t50, T51 &&t51, T52 &&t52, T53 &&t53)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
t48();
t49();
t50();
t51();
t52();
t53();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47, typename T48, typename T49, typename T50, typename T51, typename T52, typename T53, typename T54>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47, T48 &&t48, T49 &&t49, T50 &&t50, T51 &&t51, T52 &&t52, T53 &&t53, T54 &&t54)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
t48();
t49();
t50();
t51();
t52();
t53();
t54();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47, typename T48, typename T49, typename T50, typename T51, typename T52, typename T53, typename T54, typename T55>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47, T48 &&t48, T49 &&t49, T50 &&t50, T51 &&t51, T52 &&t52, T53 &&t53, T54 &&t54, T55 &&t55)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
t48();
t49();
t50();
t51();
t52();
t53();
t54();
t55();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47, typename T48, typename T49, typename T50, typename T51, typename T52, typename T53, typename T54, typename T55, typename T56>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47, T48 &&t48, T49 &&t49, T50 &&t50, T51 &&t51, T52 &&t52, T53 &&t53, T54 &&t54, T55 &&t55, T56 &&t56)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
t48();
t49();
t50();
t51();
t52();
t53();
t54();
t55();
t56();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47, typename T48, typename T49, typename T50, typename T51, typename T52, typename T53, typename T54, typename T55, typename T56, typename T57>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47, T48 &&t48, T49 &&t49, T50 &&t50, T51 &&t51, T52 &&t52, T53 &&t53, T54 &&t54, T55 &&t55, T56 &&t56, T57 &&t57)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
t48();
t49();
t50();
t51();
t52();
t53();
t54();
t55();
t56();
t57();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47, typename T48, typename T49, typename T50, typename T51, typename T52, typename T53, typename T54, typename T55, typename T56, typename T57, typename T58>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47, T48 &&t48, T49 &&t49, T50 &&t50, T51 &&t51, T52 &&t52, T53 &&t53, T54 &&t54, T55 &&t55, T56 &&t56, T57 &&t57, T58 &&t58)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
t48();
t49();
t50();
t51();
t52();
t53();
t54();
t55();
t56();
t57();
t58();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47, typename T48, typename T49, typename T50, typename T51, typename T52, typename T53, typename T54, typename T55, typename T56, typename T57, typename T58, typename T59>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47, T48 &&t48, T49 &&t49, T50 &&t50, T51 &&t51, T52 &&t52, T53 &&t53, T54 &&t54, T55 &&t55, T56 &&t56, T57 &&t57, T58 &&t58, T59 &&t59)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
t48();
t49();
t50();
t51();
t52();
t53();
t54();
t55();
t56();
t57();
t58();
t59();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47, typename T48, typename T49, typename T50, typename T51, typename T52, typename T53, typename T54, typename T55, typename T56, typename T57, typename T58, typename T59, typename T60>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47, T48 &&t48, T49 &&t49, T50 &&t50, T51 &&t51, T52 &&t52, T53 &&t53, T54 &&t54, T55 &&t55, T56 &&t56, T57 &&t57, T58 &&t58, T59 &&t59, T60 &&t60)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
t48();
t49();
t50();
t51();
t52();
t53();
t54();
t55();
t56();
t57();
t58();
t59();
t60();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47, typename T48, typename T49, typename T50, typename T51, typename T52, typename T53, typename T54, typename T55, typename T56, typename T57, typename T58, typename T59, typename T60, typename T61>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47, T48 &&t48, T49 &&t49, T50 &&t50, T51 &&t51, T52 &&t52, T53 &&t53, T54 &&t54, T55 &&t55, T56 &&t56, T57 &&t57, T58 &&t58, T59 &&t59, T60 &&t60, T61 &&t61)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
t48();
t49();
t50();
t51();
t52();
t53();
t54();
t55();
t56();
t57();
t58();
t59();
t60();
t61();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47, typename T48, typename T49, typename T50, typename T51, typename T52, typename T53, typename T54, typename T55, typename T56, typename T57, typename T58, typename T59, typename T60, typename T61, typename T62>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47, T48 &&t48, T49 &&t49, T50 &&t50, T51 &&t51, T52 &&t52, T53 &&t53, T54 &&t54, T55 &&t55, T56 &&t56, T57 &&t57, T58 &&t58, T59 &&t59, T60 &&t60, T61 &&t61, T62 &&t62)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
t48();
t49();
t50();
t51();
t52();
t53();
t54();
t55();
t56();
t57();
t58();
t59();
t60();
t61();
t62();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47, typename T48, typename T49, typename T50, typename T51, typename T52, typename T53, typename T54, typename T55, typename T56, typename T57, typename T58, typename T59, typename T60, typename T61, typename T62, typename T63>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47, T48 &&t48, T49 &&t49, T50 &&t50, T51 &&t51, T52 &&t52, T53 &&t53, T54 &&t54, T55 &&t55, T56 &&t56, T57 &&t57, T58 &&t58, T59 &&t59, T60 &&t60, T61 &&t61, T62 &&t62, T63 &&t63)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
t48();
t49();
t50();
t51();
t52();
t53();
t54();
t55();
t56();
t57();
t58();
t59();
t60();
t61();
t62();
t63();
}
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11, typename T12, typename T13, typename T14, typename T15, typename T16, typename T17, typename T18, typename T19, typename T20, typename T21, typename T22, typename T23, typename T24, typename T25, typename T26, typename T27, typename T28, typename T29, typename T30, typename T31, typename T32, typename T33, typename T34, typename T35, typename T36, typename T37, typename T38, typename T39, typename T40, typename T41, typename T42, typename T43, typename T44, typename T45, typename T46, typename T47, typename T48, typename T49, typename T50, typename T51, typename T52, typename T53, typename T54, typename T55, typename T56, typename T57, typename T58, typename T59, typename T60, typename T61, typename T62, typename T63, typename T64>
__forceinline void ONCE(T1 &&t1, T2 &&t2, T3 &&t3, T4 &&t4, T5 &&t5, T6 &&t6, T7 &&t7, T8 &&t8, T9 &&t9, T10 &&t10, T11 &&t11, T12 &&t12, T13 &&t13, T14 &&t14, T15 &&t15, T16 &&t16, T17 &&t17, T18 &&t18, T19 &&t19, T20 &&t20, T21 &&t21, T22 &&t22, T23 &&t23, T24 &&t24, T25 &&t25, T26 &&t26, T27 &&t27, T28 &&t28, T29 &&t29, T30 &&t30, T31 &&t31, T32 &&t32, T33 &&t33, T34 &&t34, T35 &&t35, T36 &&t36, T37 &&t37, T38 &&t38, T39 &&t39, T40 &&t40, T41 &&t41, T42 &&t42, T43 &&t43, T44 &&t44, T45 &&t45, T46 &&t46, T47 &&t47, T48 &&t48, T49 &&t49, T50 &&t50, T51 &&t51, T52 &&t52, T53 &&t53, T54 &&t54, T55 &&t55, T56 &&t56, T57 &&t57, T58 &&t58, T59 &&t59, T60 &&t60, T61 &&t61, T62 &&t62, T63 &&t63, T64 &&t64)
{
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
t21();
t22();
t23();
t24();
t25();
t26();
t27();
t28();
t29();
t30();
t31();
t32();
t33();
t34();
t35();
t36();
t37();
t38();
t39();
t40();
t41();
t42();
t43();
t44();
t45();
t46();
t47();
t48();
t49();
t50();
t51();
t52();
t53();
t54();
t55();
t56();
t57();
t58();
t59();
t60();
t61();
t62();
t63();
t64();
}
| true |
aacdc5db117245dc81f8ab138ac62b2e3488c779 | C++ | veodev/av_training | /defcore/EventManager_Qt.cpp | UTF-8 | 3,413 | 2.75 | 3 | [] | no_license | #include <ctime>
#include <QDebug>
#include "EventManager_Qt.h"
cEventManager_Qt::cEventManager_Qt()
{
pthread_mutex_init(&_eventMutex, nullptr);
pthread_cond_init(&_eventCond, nullptr);
pthread_mutex_init(&_dataMutex, nullptr);
}
cEventManager_Qt::~cEventManager_Qt()
{
qDebug() << "Deleting EventManager_Qt...";
}
bool cEventManager_Qt::CreateNewEvent(unsigned long id)
{
return WriteEventData(&id, sizeof(id));
}
bool cEventManager_Qt::WriteEventData(void* ptr, unsigned int size)
{
Q_ASSERT(ptr != nullptr);
pthread_mutex_lock(&_dataMutex);
unsigned char* iter = reinterpret_cast<unsigned char*>(ptr);
std::copy_n(&iter[0], size, std::back_inserter(_queue));
pthread_mutex_unlock(&_dataMutex);
return true;
}
void cEventManager_Qt::Post()
{
pthread_mutex_lock(&_eventMutex);
pthread_cond_broadcast(&_eventCond);
pthread_mutex_unlock(&_eventMutex);
}
bool cEventManager_Qt::WaitForEvent()
{
bool rc = false;
struct timespec ts;
ts.tv_nsec = 0;
ts.tv_sec = 0;
pthread_mutex_lock(&_eventMutex);
clock_gettime(CLOCK_REALTIME, &ts);
ts.tv_sec += 1;
rc = (pthread_cond_timedwait(&_eventCond, &_eventMutex, &ts) == 0);
pthread_mutex_unlock(&_eventMutex);
return rc;
}
int cEventManager_Qt::EventDataSize()
{
pthread_mutex_lock(&_dataMutex);
size_t temp = _queue.size();
pthread_mutex_unlock(&_dataMutex);
return static_cast<int>(temp);
}
bool cEventManager_Qt::ReadEventData(void* ptr, unsigned int size, unsigned long* read)
{
Q_ASSERT(ptr != nullptr);
pthread_mutex_lock(&_dataMutex);
size_t length = _queue.size();
if (size > length) {
pthread_mutex_unlock(&_dataMutex);
return false;
}
std::deque<unsigned char>::iterator endIt = _queue.begin() + static_cast<int>(size);
std::move(_queue.begin(), endIt, reinterpret_cast<unsigned char*>(ptr));
_queue.erase(_queue.begin(), endIt);
pthread_mutex_unlock(&_dataMutex);
if (read != nullptr) {
*read = length;
}
return true;
}
bool cEventManager_Qt::PeekEventData(void* ptr, unsigned int size, unsigned long* lpBytesRead, unsigned long* lpTotalBytesAvail, unsigned long* lpBytesLeftThisMessage)
{
Q_UNUSED(ptr);
Q_UNUSED(size);
Q_UNUSED(lpBytesRead);
Q_UNUSED(lpTotalBytesAvail);
Q_UNUSED(lpBytesLeftThisMessage);
return false;
}
void cEventManager_Qt::WriteHeadBodyAndPost(unsigned long Id, void* headptr, unsigned int headsize, void* bodyptr, unsigned int bodysize)
{
Q_ASSERT(headptr != nullptr);
Q_ASSERT(bodyptr != nullptr);
pthread_mutex_lock(&_dataMutex);
std::copy_n(reinterpret_cast<unsigned char*>(&Id), sizeof(Id), std::back_inserter(_queue));
std::copy_n(reinterpret_cast<unsigned char*>(headptr), headsize, std::back_inserter(_queue));
std::copy_n(reinterpret_cast<unsigned char*>(bodyptr), bodysize, std::back_inserter(_queue));
pthread_mutex_unlock(&_dataMutex);
Post();
}
void cEventManager_Qt::WriteHeadAndPost(unsigned long Id, void* headptr, unsigned int headsize)
{
Q_ASSERT(headptr != nullptr);
pthread_mutex_lock(&_dataMutex);
std::copy_n(reinterpret_cast<unsigned char*>(&Id), sizeof(Id), std::back_inserter(_queue));
std::copy_n(reinterpret_cast<unsigned char*>(headptr), headsize, std::back_inserter(_queue));
pthread_mutex_unlock(&_dataMutex);
Post();
}
| true |
60f3f850da7008314470e7b47820772bce087c1b | C++ | hthuynh2/Sava | /include/ShortestPath.cpp | UTF-8 | 1,960 | 2.875 | 3 | [] | no_license | #include "App.h"
#include "Vertex.h"
#include "Graph.h"
class ShortestPathVertex: public Vertex<int, int, int>{
public:
ShortestPathVertex(){
source_id = 1;
}
void compute(vector<int>& msgs);
void init_vertex_val(){
*MutableValue() = INT_MAX;
}
private:
int source_id;
};
class App_ShortestPath: public App_Base{
public:
App_ShortestPath();
void set_app_info();
private:
string app_name;
};
App_ShortestPath::App_ShortestPath(){
app_name = "ShortestPath";
}
void App_ShortestPath::set_app_info(){
auto ptr = new Graph<ShortestPathVertex, int> (true, true); //weighted, directed
set_graph_ptr(ptr);
set_file_name("ShortestPathGraph.txt");
}
void ShortestPathVertex::compute(vector<int>& msgs){
Reactivate();
int mindist ;
if(stoi(get_vertex_id()) == source_id){
mindist = 0;
}
else{
mindist = INT_MAX;
}
for(auto it = msgs.begin(); it != msgs.end() ;it ++){
mindist = min(mindist, *it);
}
if(mindist < GetValue()){
*MutableValue() = mindist;
auto it_start = GetOutEdgeIterator_Start();
auto it_end = GetOutEdgeIterator_End();
while(it_start != it_end){
int send_value;
if(INT_MAX - it_start->second < mindist){
send_value = INT_MAX;
}
else{
send_value = mindist + it_start->second;
}
SendMessageTo(it_start->first, send_value);
it_start++;
}
}
VoteToHalt();
return;
}
extern "C" void* create_v_t() {
return new ShortestPathVertex();
}
extern "C" void destroy_v_t(void* p) {
App_ShortestPath* p_ = (App_ShortestPath*)p;
delete p_;
}
extern "C" void* create_a_t() {
return new App_ShortestPath();
}
extern "C" void destroy_a_t(void* p) {
ShortestPathVertex* p_ = (ShortestPathVertex*)p;
delete p_;
}
| true |
73c385b6dbf844520eb9db4d800930566b1f3980 | C++ | dshnightmare/LeetCodeC | /src/RestoreIPAddress.cpp | UTF-8 | 1,147 | 3.265625 | 3 | [] | no_license | #include <vector>
#include <sstream>
#include <string>
using namespace std;
class Solution{
public:
vector<string> restoreIpAddresses(string s){
stringstream stream;
return generate(4, s, stream);
}
vector<string> generate(int n, string s, stringstream &stream){
vector<string> result;
if(s.length() < n || s.length() > 3 * n)
return result;
int num;
if(n == 1){
string s1;
stream.clear();
stream << s;
stream >> num;
stream.clear();
stream << num;
stream >> s1;
if(num < 256 && s1 == s)
result.push_back(s);
return result;
}
for(int i = 1; i <= min(3, (int)s.length()); i++){
string t1, t2;
t1 = s.substr(0, i);
stream.clear();
stream << t1;
stream >> num;
stream.clear();
stream << num;
stream >> t2;
//cout << t1 << " " << num << " " << t2 << endl;
if(num < 256 && t1 == t2){
vector<string> last = generate(n - 1, s.substr(i), stream);
for(auto j : last)
result.push_back(t1 + '.' + j);
}
}
return result;
}
};
int main(){
Solution s;
vector<string> v = s.restoreIpAddresses("1111");
for(auto i : v)
cout << i << endl;
return 0;
} | true |
d32d06cfc2ccbbce551d51175d9caa270c26e84b | C++ | Karacapps22/BuddyMemoryAllocator | /final_code/Main.cpp | UTF-8 | 2,116 | 3.015625 | 3 | [] | no_license |
#include <stdlib.h>
#include <stdio.h>
#include "Ackerman.h"
#include "BuddyAllocator.h"
//#include "BuddyAllocator.cpp"
//#include "Ackerman.cpp"
#include <getopt.h>
void easytest(BuddyAllocator* ba){
ba->printlist();
cout << "allocating 1 byte" << endl;
char * mem = (char *) ba->alloc (1);
ba->printlist();
cout << endl;
cout << "allocating 100 bytes" << endl;
char * mem1 = (char *) ba->alloc (100);
ba->printlist();
cout << endl;
cout << "allocating 200 bytes" << endl;
char * mem3 = (char *) ba->alloc (200);
ba->printlist();
cout << endl;
cout << "freeing 1 byte " << endl;
ba->free (mem);
ba->printlist();
cout << endl;
cout << "freeing 100 byte " << endl;
ba->free (mem1);
ba->printlist();
cout << endl;
cout << "freeing 200 byte " << endl;
ba->free (mem3);
ba->printlist();
cout << endl;
cout << "***test complete" << endl;
ba->printlist(); // shouldn't the list now look like as in the beginning
}
int main(int argc, char** argv) {
int opt=0;
int basic_block_size=128, memory_length=512*1024;
while((opt=getopt(argc, argv, "b:s:")) !=-1){
switch(opt){
case 'b':
basic_block_size = atoi(optarg);
break;
case 's':
memory_length = atoi(optarg);
break;
}//end block for switch
} //end block for whil
cout << basic_block_size <<endl;
cout << memory_length << endl;
// create memory manager
BuddyAllocator * allocator = new BuddyAllocator(basic_block_size, memory_length);
// the following won't print anything until you start using FreeList and replace the "new" with your own implementation
easytest (allocator);
// stress-test the memory manager, do this only after you are done with small test cases
cout << endl;
cout << "testing ackerman" << endl;
Ackerman* am = new Ackerman ();
am->test(allocator);
// destroy memory manager
delete allocator;
}
| true |
820672878580eb8c6df8be5aef971447d6c2be4d | C++ | gitter-badger/BoostTutorials | /Random/Random1/Source/main.cpp | UTF-8 | 2,777 | 2.921875 | 3 | [
"MIT"
] | permissive | /*
Copyright (c) 2015-2017 Xavier Leclercq
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.
*/
#include <boost/random/random_device.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <iostream>
#include <vector>
#include <ctime>
int main(int argc, char* argv[])
{
// Create a random number generator using the platform default
boost::random_device rng;
std::cout << "Random number generator:" << std::endl;
std::cout << "\tMin generated number: " << rng.min() << std::endl;
std::cout << "\tMax generated number: " << rng.max() << std::endl;
std::cout << std::endl;
// Create a Mersenne Twister pseudo-random number generator
boost::random::mt19937 prng;
std::cout << "Pseudo-random number generator:" << std::endl;
std::cout << "\tMin generated number: " << prng.min() << std::endl;
std::cout << "\tMax generated number: " << prng.max() << std::endl;
std::cout << std::endl;
// Generate a random number to be used as the seed
unsigned int seed = rng();
std::cout << "The seed is: " << seed << std::endl;
std::cout << std::endl;
prng.seed(seed);
// Generate a few pseudo-random numbers one by one
std::cout << "Pseudo-random number 1: " << prng() << std::endl;
std::cout << "Pseudo-random number 2: " << prng() << std::endl;
std::cout << "Pseudo-random number 3: " << prng() << std::endl;
std::cout << std::endl;
// Fill a vector with pseudo-random numbers
std::vector<unsigned int> v;
v.resize(5);
prng.generate(v.begin(), v.end());
std::cout << "Pseudo-random numbers vector: ";
for (size_t i = 0; i < v.size(); ++i)
{
std::cout << v[i] << " ";
}
std::cout << std::endl;
return 0;
}
| true |
3859fa3e0501141d16313be2556ae2ace46a4e11 | C++ | DarthCoder117/RRDTP | /cpp/test/LocalStoreTest.cpp | UTF-8 | 674 | 3.046875 | 3 | [
"MIT"
] | permissive | #include <RRDTP/LocalStore.h>
#include <RRDTP/Entry.h>
#include <cassert>
int main()
{
rrdtp::LocalStore localStore;
//Test integer storage
/*rrdtp::Entry* entry = localStore.Create(-1, "test-int", rrdtp::EDT_INT);
assert(entry != NULL);
entry->Set<int>(123456789);
assert(entry->Get<int>() == 123456789);
//Test setting values directly
int testInt = 8726348;
entry->Set((unsigned char*)&testInt, sizeof(int));
assert(entry->Get<int>() == 8726348);
//Test setting strings
entry->SetString("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
assert(strcmp(entry->GetString(), "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z") == 0);*/
return 0;
} | true |
5a1023c8a23fd0115a7c9379d5eccac26cd27291 | C++ | smacdo/euler | /src/problems/problem_9.cpp | UTF-8 | 868 | 3.125 | 3 | [] | no_license | #include "projecteuler.h"
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
REGISTER_PROBLEM(9, "Find pythagorean triple a+b+c=1000")
void problem_9( const std::vector<std::string>& args )
{
bool bAnswer = false;
for ( int a = 1; a < 1000 && !bAnswer; ++a )
{
for ( int b = 1; b < 1000; ++b )
{
if ( a + b + sqrt( a*a + b*b ) == 1000 )
{
int c = sqrt( a*a + b*b );
std::cout << "a=" << a << std::endl;
std::cout << "b=" << b << std::endl;
std::cout << "c=" << c << std::endl;
std::cout << "abc=" << a * b * c << std::endl;
bAnswer = true;
break;
}
}
}
if (! bAnswer )
{
std::cerr << "Failed to find a solution" << std::endl;
}
}
| true |
18a01702f978fdca9dd6898e63f9e1f3f9ab8ba5 | C++ | bytemaster/fc | /include/fc/io/json.hpp | UTF-8 | 1,808 | 2.59375 | 3 | [
"MIT"
] | permissive | #pragma once
#include <fc/variant.hpp>
namespace fc
{
class path;
class ostream;
class buffered_istream;
/**
* Provides interface for json serialization.
*
* json strings are always UTF8
*/
class json
{
public:
static ostream& to_stream( ostream& out, const fc::string& );
static ostream& to_stream( ostream& out, const variant& v );
static ostream& to_stream( ostream& out, const variants& v );
static ostream& to_stream( ostream& out, const variant_object& v );
static variant from_stream( buffered_istream& in );
static variant from_string( const string& utf8_str );
static string to_string( const variant& v );
static string to_pretty_string( const variant& v );
template<typename T>
static void save_to_file( const T& v, const fc::path& fi, bool pretty = true )
{
save_to_file( variant(v), fi, pretty );
}
static void save_to_file( const variant& v, const fc::path& fi, bool pretty = true );
static variant from_file( const fc::path& p );
template<typename T>
static T from_file( const fc::path& p )
{
return json::from_file(p).as<T>();
}
template<typename T>
static string to_string( const T& v )
{
return to_string( variant(v) );
}
template<typename T>
static string to_pretty_string( const T& v )
{
return to_pretty_string( variant(v) );
}
template<typename T>
static void save_to_file( const T& v, const string& p, bool pretty = true )
{
save_to_file( variant(v), p, pretty );
}
};
} // fc
| true |
45a665c51128b9ad5099ae181b5ae24092267fbf | C++ | lysiak-yevhenii/cpp | /Pointers_to_members/main.cpp | UTF-8 | 1,361 | 4.15625 | 4 | [] | no_license | #include <iostream>
using namespace std;
//Pointers to members allow to refer to nonstatic members of class objects.
//You can not use a pointer to member to point to a static class member
//because the address of a static member is not associated with any particular
//object. To point to a static class member, you must use a normal pointer.
class X
{
public:
int a;
void f(int b);
};
void X::f(int b)
{
cout << "The balue of b is " << b << endl;
}
//To redice vomplex syntax, you can declare a typedef to be a pointer
//to member.
typedef int X::*var_ptr;
typedef void (X::*func_ptr)(int);
int main(void)
{
int *ptr;
//deckate pointer to data member
int X::*ptiptr = &X::a;
//declare a pointer to member function
void (X::*ptiptf) (int) = &X::f;
//create an object of class type X
X xobject;
xobject.*ptiptr = 10;
(xobject.*ptiptf)(20);
cout << "The value of " << xobject.a << endl;
//Declaration
var_ptr var = &X::a;
func_ptr func = &X::f;
X xt_object;
xt_object.a = 10;
xt_object.*var = 5;
cout << xt_object.a << endl;
// The pointer to member operators .* and ->*
// are used to bind a pointer to a member of
// a specific class object. Because the precedence
// of () (function call operator) is higher than
// .* and ->*, you must use parentheses to call
// the function pointed to by ptf.
return (0);
}
| true |
f5b7820e7cd0b6d678c6399fc68375e20e854339 | C++ | lioneltn/pos | /order.cpp | UTF-8 | 3,845 | 2.71875 | 3 | [] | no_license | #include "order.h"
#include "order.h"
#include <QDateTime>
#include <QSqlQuery>
#include <QtSql>
Order::Order()
{
OrderDetail *OD=new OrderDetail();
}
Order::Order(int id_client,int id_emp,int id_caisse)
{
TOTAL=0;
QSqlQuery query;
query.prepare("SELECT ID_COM+1 FROM COMMANDE_TMP WHERE ID_CLIENT=:idc");
query.bindValue(":idc",id_client);
query.exec();
while (query.next()) {
ID=query.value(0).toInt();
}
ID_EMP=id_emp;
CLIENT_ID=id_client;
ID_CAISSE=id_caisse;
DATE=QDateTime::currentDateTime().toString("dddd dd MMMM yyyy");
//**Populating Order Detail**//
query.prepare("SELECT * FROM DETAIL_COMMANDE_TMP WHERE ID_COM=:id");
query.bindValue(":id",ID);
query.exec();
while(query.next()){
int ID_PRODUIT;
ID_PRODUIT=query.value(1).toInt();
OrderDetail *OD= new OrderDetail(ID_PRODUIT,ID);
OD->setQte(query.value(2).toInt());
OD->setTotal(OD->getQte()*static_cast<float>(OD->getPrice()));
TOTAL=TOTAL+OD->getTotal();
vDetails.push_back(OD);
}
}
void Order::setID(int ID1){
ID=ID1;
}
void Order::setID_CAISSE(int ID1){
ID_CAISSE=ID1;
}
void Order::setID_EMP(int ID1){
ID_EMP=ID1;
}
QString Order::getDATE(){
return DATE;
}
int Order::getID(){
return ID;
}
int Order::getID_CAISSE(){
return ID_CAISSE;
}
int Order::getID_EMP(){
return ID_EMP;
}
void Order::setPType(QString type){
PType=type;
}
QString Order::getPType(){
return PType;
}
int Order::getCLientID()
{
return CLIENT_ID;
}
float Order::getTotal()
{
return TOTAL;
}
bool Order::ClearData()
{ bool done=false;
bool done1=false;
QSqlQuery query;
query.prepare("DELETE FROM DETAIL_COMMANDE_TMP WHERE ID_COM=:id_com");
query.bindValue(":id_com",getID());
query.exec();
if (query.numRowsAffected()>0){
done1=true;
}
else {
done1=false;
}
bool done2=false;
query.prepare("DELETE FROM COMMANDE_TMP WHERE ID_COM=:id_com");
query.bindValue(":id_com",getID());
query.exec();
if (query.numRowsAffected()>0){
done1=true;
}
else {
done1=false;
}
if (done1 && done2){
done=true;
}
return done;
}
void Order::setTotal(float total1)
{
TOTAL=total1;
}
Order::~Order()
{
for (unsigned j=0;j<vDetails.size();j++)
{
delete vDetails[j];
}
vDetails.clear();
}
void Order::addProduct(OrderDetail *e){
vDetails.push_back(e);
}
bool Order::removeProduct(unsigned i){
if(i >= 0 && i < vDetails.size())
{
vDetails.erase(vDetails.begin()+ i-1);
return true;
}
else
{
return false;
}
}
bool Order::saveOrderDetail(){
bool done;
done=false;
for(unsigned i=0; i<vDetails.size(); i++){
QSqlQuery query;
query.prepare("INSERT INTO DETAIL_COMMANDE (ID,ID_PRODUIT,QTE,ID_COM)"
"VALUES(:id,:id_produit,:qte,:id_com)");
query.bindValue(":id",vDetails[i]->getID());
query.bindValue(":id_produit",vDetails[i]->getIDProduit());
query.bindValue(":qte",vDetails[i]->getQte());
query.bindValue(":id_com",vDetails[i]->getIDCom());
query.exec();
if (query.numRowsAffected()>0){
done=true;
}
else {
done=false;
}
}
return done;
}
bool Order::saveOrder(){
QSqlQuery query;
bool done;
done=false;
query.prepare("INSERT INTO COMMANDE (ID_COM,DATE_COM,PAYMENT_TYPE,ID_CAISSE,ID_EMP)"
"VALUES(:id,:date,:type,:id_caisse,:id_emp)");
query.bindValue(":id",getID());
query.bindValue(":date",getDATE());
query.bindValue(":id_caisse",getID_CAISSE());
query.bindValue(":type",getPType());
query.bindValue(":id_emp",getID_EMP());
query.exec();
if (query.numRowsAffected()>0){
done=true;
}
return done;
}
| true |
39d4558bfb89368f5680f3901ac53259b0f30031 | C++ | Lruihao/c-code | /cpp/大二暑假/Dreamoon and WiFi.cpp | WINDOWS-1252 | 1,696 | 2.734375 | 3 | [] | no_license | #include<bits/stdc++.h>
using namespace std;
/*int main(){
int i,j,cnt=0;
long long c[11][11],sum=0,sum1=0;
for(i = 0; i < 11; i++){//
c[i][0] = 1;
c[i][i] = 1;
for(j = 1; j < i; j++)
c[i][j] = c[i-1][j] + c[i-1][j-1];
}
string a,b;
cin>>a>>b;
//cout<<a<<endl<<b<<endl;
int len=a.length();
for(i=0;i<len;i++)
if(a[i]=='+') sum+=1;
else sum-=1;
for(i=0;i<b.length();i++){
if(b[i]=='+') sum1+=1;
else if(b[i]=='-')sum1-=1;
if(b[i]=='?') cnt++;
}
if(sum==sum1&&cnt==0){
printf("1.000000000000\n");
return 0;
}
int flag=0;
long long x=0;
for(j=0;j<=cnt;j++)
x+=c[cnt][j];
//cout<<x<<endl;
for(i=0;i<=cnt;i++)
if(cnt-2*i+sum1==sum){
flag=1;
long double y=c[cnt][i]*1.0/x;
printf("%.12llf\n",y);
}
if(!flag)printf("0.000000000000\n");
return 0;
}*/
int main(){
string a,b;
int x,y,z,p,q,c[11][11],i,j;
for(i = 0; i < 11; i++){//
c[i][0] = 1;
c[i][i] = 1;
for(j = 1; j < i; j++)
c[i][j] = c[i-1][j] + c[i-1][j-1];
}
cin>>a;
cin>>b;
x=y=z=p=q=0;
for(i=0;i<a.length();i++)
if(a[i]=='+') x++;
else y++;
for(i=0;i<b.length();i++){
if(b[i]=='+') p++;
else if(b[i]=='-') q++;
else z++;
}
if(x==p&&z==0){
printf("1.000000000000\n");
return 0;
}
if(x-p<0||y-q<0) {
printf("0.000000000000\n");
return 0;
}
x=x-p;
printf("%0.12f",c[z][x]*1.0/(2<<(z-1)));
return 0;
}
| true |
5849981b2301816df596577c6b8a61a515dba78c | C++ | jinrongsyb17/homework-space | /金泽俊/第五次作业-2017310345-金泽俊-17金融实验/8-4.cpp | UTF-8 | 447 | 3.53125 | 4 | [] | no_license | #include<iostream>
using namespace std;
class Counter
{public:
Counter(int i): i(i){};
~Counter() {};
void show(){cout<<i<<ends;};
friend Counter operator + (const Counter &o1, const Counter &o2);
private:
int i;
};
Counter operator + (const Counter &o1, const Counter &o2)
{return Counter (o1.i + o2.i);}
int main ()
{
Counter c_1(2);
Counter c_2(3);
Counter c_3=c_1+c_2;
c_3.show();
return 0;
}
| true |
b12a39a1b59cab5de7fd322d7dafae2386c3a31a | C++ | jonasla/icpc | /simulacros/TAP2016/j.cpp | UTF-8 | 636 | 2.59375 | 3 | [] | no_license | #include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define forn(i,n) for(int i=0; i<(int)n; i++)
#define forsn(i,s,n) for(int i=int(s); i<(int)n; i++)
typedef long long tint;
int main()
{
tint n,l,c;
ios::sync_with_stdio(false);
cin.tie(NULL);
while (cin >> n >> l >> c)
{
vector<tint> k (n);
forn(i,n)
cin >> k[i];
sort(k.begin(),k.end());
reverse(k.begin(),k.end());
tint r = 0;
bool gane = true;
for(tint i = 0; i < n; i += l)
{
if (c - r >= k[i])
r += k[i];
else
gane = false;
}
if (gane)
cout << "S\n";
else
cout << "N\n";
}
}
| true |
a5b34bfd330de9ab0450904df50a64ea4c527c6b | C++ | Cauahu/hihoCoder-training | /strcpy/strcpy.cpp | UTF-8 | 384 | 3.125 | 3 | [] | no_license | #include <iostream>
#include <stdio.h>
#include <assert.h>
#include <string.h>
using namespace std;
char * strcpy_(char * dest, const char * src)
{
assert((dest != NULL) && (src != NULL));
char * address = dest;
while(*src != '\0')
*dest++ = *src;
return address;
}
int main()
{
char s[] = "123456789";
char d[] = "123";
strcpy(d,s);
printf("%s,%s\n",d,s);
return 0;
}
| true |
a0fff75de7ec6680dfa56759474de3a07d498cb7 | C++ | Doresimon/my-ref | /snippet/sort/algorithm.sort.cpp | UTF-8 | 2,654 | 3.75 | 4 | [] | no_license | /**
* compared with js.array.sort()
*
* C++ sort function uses introsort which is a hybrid algorithm.
* Different implementations use different algorithms.
* The GNU Standard C++ library, for example,
* uses a 3-part hybrid sorting algorithm:
* introsort is performed first
* (introsort itself being a hybrid of quicksort and heap sort)
* followed by an insertion sort on the result.
*
* The new C++11 standard requires that the complexity
* of sort to be O(Nlog(N)) in the worst case.
*
*/
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int asc(int x, int y)
{
return x < y;
}
int desc(int x, int y)
{
return x > y;
}
void printVector(const vector<int> &arr)
{
auto it = arr.begin();
auto end = arr.end();
std::cout << "[";
while (it != end)
{
cout << *it << " ";
it++;
}
std::cout << "]" << endl;
return;
}
class Node
{
public:
int v; // value
int i; // index
static int cnt;
Node(int v);
static void printCnt();
static void printVector(const vector<Node> &V);
static int asc(const Node &x, const Node &y);
static int desc(const Node &x, const Node &y);
};
int Node::cnt = 0;
Node::Node(int v)
{
this->v = v;
this->i = Node::cnt;
Node::cnt++;
}
void Node::printCnt()
{
cout << "Node.cnt = " << Node::cnt << endl;
return;
}
void Node::printVector(const vector<Node> &V)
{
auto it = V.begin();
auto end = V.end();
std::cout << "[";
while (it != end)
{
cout << (*it).v << " ";
it++;
}
std::cout << "]" << endl;
return;
}
int Node::asc(const Node &x, const Node &y)
{
return x.v - y.v;
}
int Node::desc(const Node &x, const Node &y)
{
return y.v - x.v;
}
int main()
{
int arr[] = {11, 77, 66, 33, 22, 55, 44, 88, 99, 0};
vector<int> ARR = vector<int>(arr, arr + sizeof(arr) / sizeof(int));
printVector(ARR);
//range = [begin, end)
std::sort(ARR.begin(), ARR.end()); // default is ascending
std::sort(ARR.begin(), ARR.end(), asc); // self defined ascending
std::sort(ARR.begin(), ARR.end(), desc); // self defined descending
printVector(ARR);
vector<Node> ARR_Node;
for (auto it = ARR.begin(); it != ARR.end(); it++)
{
ARR_Node.push_back(Node(*it));
}
Node::printCnt();
Node::printVector(ARR_Node);
std::sort(ARR_Node.begin(), ARR_Node.end(), Node::asc);
Node::printVector(ARR_Node);
Node::printCnt();
std::sort(ARR_Node.begin(), ARR_Node.end(), Node::desc);
Node::printVector(ARR_Node);
Node::printCnt();
return 0;
} | true |
ae5a7953b08d91d2e4ed12d87c6797f60873b0d3 | C++ | tectronics/hapro | /Game2/Potion.cpp | UTF-8 | 1,885 | 2.5625 | 3 | [] | no_license | #include "Potion.h"
#include "Game.h"
#include "ObjectDatabase.h"
#include "StringLib.h"
#include "Renderer.h"
#include "Util.h"
#include "Level.h"
#include "Tile.h"
#include "Character.h"
Potion::Potion(PotionType type, int power) : ScrambledItem(GT_IT_POTION, TH_POTION_TYPE, g_objectDatabase->getScrambledPotionType(type)) {
m_types[TH_POTION_TYPE] = type;
m_power = power;
const PotionInfo& info = g_objectDatabase->getPotionInfo(type);
m_weight = info.weight;
m_stackable = true;
}
Potion::Potion(std::ifstream& file) : ScrambledItem(GT_IT_POTION, file) {
int* tokens = Util::intSplit(file);
m_types[TH_POTION_TYPE] = tokens[0];
const PotionInfo& info = g_objectDatabase->getPotionInfo(PotionType(tokens[0]));
m_weight = info.weight;
m_stackable = true;
m_power = tokens[1];
load(TH_POTION_TYPE, g_objectDatabase->getScrambledPotionType(PotionType(tokens[0])));
delete[] tokens;
}
Potion::~Potion() {
}
void Potion::save(std::ofstream& file) const {
file << getType(TH_GENERIC_TYPE) << "\n";
ScrambledItem::save(file);
file << getType(TH_POTION_TYPE) << " " << m_power << "\n";
}
void Potion::render(float x, float y) {
g_renderer->render(*this, x, y);
}
void Potion::logDetails(TextLog& log) const {
Item::logDetails(log);
log.addBlankLine();
if(isIdentified())
log.addLine(g_stringLib->getTextString(ST_POTION_POWER, Util::intToString(m_power).c_str()));
}
void Potion::shatter(int x, int y) {
g_textLog->addLine(g_stringLib->getTextString(ST_POTION_SHATTER, getName().c_str()));
switch(getType(TH_POTION_TYPE)) {
case PT_POISON:
for(int i = -1; i <= 1; i++) {
for(int j = -1; j <= 1; j++) {
if(g_currentLevel->getTile(x+i, y+j)->getCharacter() != NULL)
g_currentLevel->getTile(x+i, y+j)->getCharacter()->addStatusEffect(SE_POISON, 200);
}
}
break;
}
reduceStackCount(1, true, g_currentLevel->getTile(x, y)->getItems());
}
| true |
e00089cd31ccfb44a93df09ad9394404ce27f3ad | C++ | Calipso341/C-my-begining- | /ClassWork/ClassWork 3.28.19/ClassWork 3.28.19/Source.cpp | UTF-8 | 2,816 | 3.375 | 3 | [] | no_license | #include<iostream>
#include<string>
#include<Windows.h>
using namespace std;
struct Player {
string name;
string surname;
unsigned short age;
string position;
int price;
void ShowPerson() {
cout << "\n\n\tName: " << name << "\n\n\tSurname: " << surname << "\n\n\tAge: " << age << "\n\n\tPosition: " << position << "\n\n\tPrice: " << price << endl;
}
};
struct Team {
public:
string country;
string city;
string name;
string coach;
unsigned short wins;
unsigned short draws;
unsigned int losses;
private:
unsigned short teamSize;
void ShowInfo() {
cout << "\n\n\tCoutnry: " << country << "\n\n\tCity: " << city << "\n\n\tName: " << name << "\n\n\tCoach: " << coach << "\n\n\tWins: " << wins << "\n\n\tDraws: " << draws << "\n\n\tLosses: " << losses << "\n\n\tTeamSize: " << teamSize << endl;
}
void SetTeamSize(short newName) {
}
Player *player = new Player[teamSize];
};
void FillPlayer(Player *player, const int teamSize) {
for (int i = 0; i < teamSize; i++)
{
cout << "\n\tEnter player name: ";
cin >> player[i].name;
cout << "\n\tEnter player surename: ";
cin >> player[i].surname;
cout << "\n\tEnter player age: ";
cin >> player[i].age;
cout << "\n\tEnter player position: ";
cin >> player[i].position;
cout << "\n\tEnter player price ";
cin >> player[i].price;
player[i].ShowPerson();
}
}
void ShowPlayer(Player *player, const int teamSize) {
for (int i = 0; i < teamSize; i++)
{
player[i].ShowPerson();
cout << "\n\t============================================" << endl;
}
}
int main() {
int teamSize = 0;
cout << "\n\tEnter team size: ";
cin >> teamSize;
system("cls");
Team Karpaty;
Karpaty.country = "Ukraine";
Karpaty.city = "Lviv";
Karpaty.coach = "Bill";
Karpaty.name = "Karpaty";
Karpaty.wins = 4;
Karpaty.losses = 4;
Karpaty.draws = 4;
Karpaty.teamSize = teamSize;
Karpaty.ShowInfo();
FillPlayer(Karpaty.player, Karpaty.teamSize);
system("cls");
ShowPlayer(Karpaty.player, Karpaty.teamSize);
/*Karpaty.player[0].name = "Robert";
Karpaty.player[0].surname = "Robertson";
Karpaty.player[0].position = "Halfback";
Karpaty.player[0].age = 25;
Karpaty.player[0].price = 25;
Karpaty.player[0].ShowPerson();
Karpaty.player[1].name = "Karl";
Karpaty.player[1].surname = "Karlson";
Karpaty.player[1].position = "Halfback";
Karpaty.player[1].age = 32;
Karpaty.player[1].price = 45555;
Karpaty.player[1].ShowPerson();
Karpaty.player[0].ShowPerson();
Karpaty.player[1].ShowPerson();*/
/*int teamSize;
cout << "\n\tEnter team size: ";
cin >> teamSize;
cout << "\n\t============================================" << endl;
Player *player = new Player[teamSize];
FillPlayer(player, teamSize);
system("cls");
ShowPlayer(player, teamSize);
delete [] player;*/
system("pause");
return 0;
} | true |
6727326109d6174e2eff19c0cb38837b31d43796 | C++ | leehosu/coding-test-cpp | /codeup/228.cpp | UHC | 377 | 2.609375 | 3 | [] | no_license | #include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
cin.tie(NULL);
ios_base::sync_with_stdio(false);
double h, m;
cin >> h >> m;
double avg_m = (h-100) * 0.9;
double bmi = (m - avg_m) * 100 / avg_m ;
if(bmi <= 10) cout << "";
else if(bmi > 10 && bmi <= 20 ) cout <<"ü";
else cout << "";
return 0;
}
| true |
bbda76f4420c1fb1b98ed127268d56ca0b61a68d | C++ | sayuree/leetcode-problems | /stack/1021.RemoveOutermostParentheses.cpp | UTF-8 | 593 | 3.359375 | 3 | [] | no_license | //O(n) time and O(n) space using Stack
//There is need to remove only outermost layer: No need to deal with nestedness
class Solution {
public:
string removeOuterParentheses(string S) {
stack<char> temp;
string res="";
for(char c:S){
if(c=='('){
if(temp.size()>0){
res+=c;
}
temp.push(c);
}else{
if(temp.size()>1){
res+=c;
}
temp.pop();
}
}
return res;
}
}; | true |
cac7b7b7d2f37eb7dcbd4a3278027a2d8960277a | C++ | shailendra-singh-dev/ProgrammingChallenges | /Caribbean Online Judge COJ/2925 - Help with the Remote.cpp | UTF-8 | 302 | 2.75 | 3 | [] | no_license | #include <cstdio>
using namespace std;
int T, A, B, cont;
int main()
{
scanf("%d", &T);
while(T--)
{
cont = 0;
scanf("%d %d", &A, &B);
if(A == B) {printf("%d\n", 0); continue;}
while(A != B)
{
if(A < B) cont++, A++;
else A /= 2, cont++;
}
printf("%d\n", cont);
}
return 0;
} | true |
9c437e0faa25d886f675cc47b9f0db05a934e930 | C++ | Sahil12S/LeetCode | /Cplusplus/Union_Find/main.cpp | UTF-8 | 812 | 3.609375 | 4 | [] | no_license | #include "union_find.cpp"
int main()
{
// Let's have 8 nodes
// 1, 2, 3, 4, 5, 6, 7, 8
VVI pairs = {{1, 2}, {1, 3}, {2, 3}, {4, 3}, {5, 6}, {6, 7}};
UnionFind uf(8);
for (auto pair : pairs)
{
uf.unify(pair[0], pair[1]);
}
std::cout << "======================" << '\n';
std::cout << "Number of connected components: " << uf.numComponents() << '\n';
std::cout << "Size of component that has element 1: " << uf.componentSize(1) << '\n';
std::cout << "Size of component that has element 6: " << uf.componentSize(6) << '\n';
std::cout << "Are 1 & 4 connected? " << uf.isConnected(1, 4) << '\n';
std::cout << "Are 3 & 6 connected? " << uf.isConnected(3, 6) << '\n';
std::cout << "Are 5 & 8 connected? " << uf.isConnected(5, 8) << '\n';
return 0;
} | true |
db778073fada4b4e7c672eecb6291519455de434 | C++ | Rory37/Classes | /classmusic.h | UTF-8 | 733 | 3.03125 | 3 | [] | no_license | #include "classparent.h" //sets up inheretence
class classmusic : public classparent {//sets up inheretence
public:
~classmusic(); //destructor
//Sets all the virtual methods (virtual lets it overide the parent class)
virtual void setArtist(char*); //function to set artist
virtual void setPublish(char*);//function to set publisher
virtual void setDur(double); // function to set duration
virtual char* getArtist(); //function to return artist
virtual char* getPublish();//function to return publisher
virtual double getDur(); //function to return duration
char* artist;//pointer to array to store artist
char* publisher;//pointer to array to store publisher
double duration;//double to store duration
};
| true |
cd864bf650379dbfbcdd436bda5cccddedc575f5 | C++ | davidalain/RoboQuadrupede | /Sweep/Sweep.ino | UTF-8 | 3,179 | 2.59375 | 3 | [] | no_license | /* Sweep
by BARRAGAN <http://barraganstudio.com>
This example code is in the public domain.
modified 8 Nov 2013
by Scott Fitzgerald
http://arduino.cc/en/Tutorial/Sweep
*/
#include <Servo.h>
#define SERVO_ID 5
#define VERTICAL_ESQ_TRAS 0
#define LATERAL_DIAGONAL_PRINCIPAL 1
#define LATERAL_DIAGONAL_SECUNDARIA 2
#define VERTICAL_DIR_TRAS 3
#define VERTICAL_ESQ_FRENTE 4
#define VERTICAL_DIR_FRENTE 5
const int SERVO_PINS[6] = {3, 5, 6, 9, 10, 11};
const int START_ANGLES[6] = {135, 90, 160, 120, 120, 135};
int maxAngles[6] = {0, 0, 0, 0, 0, 0};
int minAngles[6] = {180, 180, 180, 180, 180, 180};
Servo servos[6];
//======================================================================================
void printAng(int servoId, int ang){
Serial.print("servoId=");
Serial.print(servoId);
Serial.print(", ang (input)=");
Serial.print(ang);
Serial.print(", ang (result)=");
Serial.println(servos[servoId].read());
}
void serAngle(int servoId, int ang){
servos[servoId].write(ang);
printAng(servoId, ang);
}
void setup()
{
Serial.begin(9600);
// for(int i = 0 ; i < 6 ; i++){
// servos[i].attach(SERVO_PINS[i]);
// delay(200);
//
// servos[i].write(START_ANGLES[i]);
// printAng(i, START_ANGLES[i]);
// delay(1000);
// }
servos[VERTICAL_ESQ_TRAS].attach(SERVO_PINS[VERTICAL_ESQ_TRAS]);
delay(200);
serAngle(VERTICAL_ESQ_TRAS, 180);
delay(1000);
serAngle(VERTICAL_ESQ_TRAS, 0);
delay(1000);
serAngle(VERTICAL_ESQ_TRAS, START_ANGLES[VERTICAL_ESQ_TRAS]);
delay(1000);
servos[VERTICAL_DIR_TRAS].attach(SERVO_PINS[VERTICAL_DIR_TRAS]);
delay(200);
serAngle(VERTICAL_DIR_TRAS, 0);
delay(1000);
serAngle(VERTICAL_DIR_TRAS, 180);
delay(1000);
serAngle(VERTICAL_DIR_TRAS, START_ANGLES[VERTICAL_DIR_TRAS]);
delay(1000);
servos[VERTICAL_ESQ_FRENTE].attach(SERVO_PINS[VERTICAL_ESQ_FRENTE]);
delay(200);
serAngle(VERTICAL_ESQ_FRENTE, 0);
delay(1000);
serAngle(VERTICAL_ESQ_FRENTE, 180);
delay(1000);
serAngle(VERTICAL_ESQ_FRENTE, START_ANGLES[VERTICAL_ESQ_FRENTE]);
delay(1000);
servos[VERTICAL_DIR_FRENTE].attach(SERVO_PINS[VERTICAL_DIR_FRENTE]);
delay(200);
serAngle(VERTICAL_DIR_FRENTE, 180);
delay(1000);
serAngle(VERTICAL_DIR_FRENTE, 0);
delay(1000);
serAngle(VERTICAL_DIR_FRENTE, START_ANGLES[VERTICAL_DIR_FRENTE]);
delay(1000);
// int ang = 190;
// while(servos[0].read() > 0){
// serAngle(0, ang);
// ang -= 2;
// delay(200);
// }
//
// ang = 0;
// while(servos[0].read() < 360){
// serAngle(0, ang);
// ang += 2;
// delay(200);
// }
}
int ang = START_ANGLES[0];
void loop()
{
int incomingByte;
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte);
if(incomingByte == '1'){
ang += 15;
}else{
ang -= 15;
}
serAngle(SERVO_ID, ang);
delay(100);
}
}
| true |
357878acace4a97a82fe2e3e391339a45b211c5b | C++ | HeroIsUseless/LeetCode | /20.cpp | UTF-8 | 1,075 | 3.609375 | 4 | [] | no_license | #include <iostream>
#include <vector>
#include <string>
using namespace std;
class Solution {
public:
bool isValid(string s) {
int n = s.size();
char *stack = new char[n];
int s_n = 0;
for(int i=0; i<n; i++){
if(s[i] == '('){
stack[s_n++] = '(';
}
if(s[i] == '['){
stack[s_n++] = '[';
}
if(s[i] == '{'){
stack[s_n++] = '{';
}
if(s[i] == ')'){
if(s_n-1>=0 && stack[s_n-1]=='(') s_n--;
else return false;
}
if(s[i] == ']'){
if(s_n-1>=0 && stack[s_n-1]=='[') s_n--;
else return false;
}
if(s[i] == '}'){
if(s_n-1>=0 && stack[s_n-1]=='{') s_n--;
else return false;
}
}
if(s_n == 0) return true;
else return false;
}
};
int main(){
string s = "([)]";
Solution solution;
cout << solution.isValid(s);
return 0;
} | true |
5f5e4184ecff656dabd155ffef914a27d191623b | C++ | UnskilledLuck/RetroLED-old | /ledtest.ino | UTF-8 | 1,803 | 2.6875 | 3 | [] | no_license | #include <FastLED.h>
#define LED_PIN 2
#define NUM_LEDS 140
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(9600);
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
}
void loop() {
int currentPin = -1;
int ledCounter = 0;
int ledOn = 0;
while(true){
leds[ledOn] = CRGB(50,50,50);
// if we're looking for input
if (currentPin == -1) {
/*for (int x = 0; x <= 10; x++){
if (analogRead(x) > 0) {
delay(1);
if (analogRead(x) > 0) {
currentPin = x;
Serial.println("input");
Serial.println(currentPin);
//Serial.println("value" + analogRead(currentPin));
}
}*/
}
delay(1);
}
else { // We have input on a pin
/*bool definitelyOn;
leds[ledOn] = CRGB(0,0,0);
switch (currentPin) {
case 0: definitelyOn = masterSystem(currentPin); break;
case 1: definitelyOn = megaDrive(currentPin); break;
case 2: definitelyOn = saturn(currentPin); break;
case 3: definitelyOn = dreamcast(currentPin); break;
case 4: definitelyOn = playstation(currentPin); break;
case 5: definitelyOn = playstation2(currentPin); break;
case 6: definitelyOn = snes(currentPin); break;
case 7: definitelyOn = n64(currentPin); break;
case 8: definitelyOn = gamecube(currentPin); break;
case 9: definitelyOn = wii(currentPin); break;
case 10: definitelyOn = xbox(currentPin); break;
default: Serial.println("Invalid state!");
}
if (definitelyOn == true) lightShow(currentPin);*/
currentPin = -1;
}
if (ledCounter == 500){
Serial.println("led on");
leds[ledOn] = CRGB(0,0,0);
ledOn++;
ledCounter = 0;
}
ledCounter++;
if (ledOn == 140) ledOn = 0;
}
} // end main loop | true |
76169e8df4c888b77c9d55ca23f39bbdd5ba0cf4 | C++ | shiwenxiang/clucene | /src/CLucene/queryParser/MultiFieldQueryParser.h | UTF-8 | 3,107 | 2.609375 | 3 | [] | no_license | #ifndef MultiFieldQueryParser_H
#define MultiFieldQueryParser_H
#include "CLucene/StdHeader.h"
#include "CLucene/analysis/AnalysisHeader.h"
#include "CLucene/search/SearchHeader.h"
#include "QueryParser.h"
using namespace lucene::index;
using namespace lucene::util;
using namespace lucene::search;
using namespace lucene::analysis;
namespace lucene{ namespace queryParser{
/**
* A QueryParser which constructs queries to search multiple fields.
*
* @author <a href="mailto:kelvin@relevanz.com">Kelvin Tan</a>
* @version $Revision: 1.2 $
*/
class MultiFieldQueryParser: public QueryParser
{
public:
static const l_byte_t NORMAL_FIELD = 0;
static const l_byte_t REQUIRED_FIELD = 1;
static const l_byte_t PROHIBITED_FIELD = 2;
/*MultiFieldQueryParser(QueryParserTokenManager tm)
{
super(tm);
}
MultiFieldQueryParser(Reader* stream):
QueryParser(stream)
{
}*/
MultiFieldQueryParser(char_t* f, Analyzer& a):
QueryParser(f,a)
{
}
/**
* <p>
* Parses a query which searches on the fields specified.
* <p>
* If x fields are specified, this effectively constructs:
* <pre>
* <code>
* (field1:query) (field2:query) (field3:query)...(fieldx:query)
* </code>
* </pre>
*
* @param query Query string to parse
* @param fields Fields to search on
* @param analyzer Analyzer to use
* @throws ParserException if query parsing fails
* @throws TokenMgrError if query parsing fails
*/
static Query& Parse(const char_t* query, const char_t** fields, const int_t fieldsLen, Analyzer& analyzer);
/**
* <p>
* Parses a query, searching on the fields specified.
* Use this if you need to specify certain fields as required,
* and others as prohibited.
* <p><pre>
* Usage:
* <code>
* String[] fields = {"filename", "contents", "description"};
* int_t[] flags = {MultiFieldQueryParser.NORMAL FIELD,
* MultiFieldQueryParser.REQUIRED FIELD,
* MultiFieldQueryParser.PROHIBITED FIELD,};
* parse(query, fields, flags, analyzer);
* </code>
* </pre>
*<p>
* The code above would construct a query:
* <pre>
* <code>
* (filename:query) +(contents:query) -(description:query)
* </code>
* </pre>
*
* @param query Query string to parse
* @param fields Fields to search on
* @param flags Flags describing the fields
* @param analyzer Analyzer to use
* @throws ParserException if query parsing fails
* @throws TokenMgrError if query parsing fails
*/
static Query& Parse(const char_t* query, const char_t** fields, const int_t fieldsLen, const l_byte_t* flags, Analyzer& analyzer);
};
}}
#endif
| true |
23e648a83f95d8261109f962d4fd6d197cd90803 | C++ | Chimnii/Algospot | /Problems/Programmers/Lv2.150368.cpp | UTF-8 | 1,419 | 3.21875 | 3 | [] | no_license | #include <string>
#include <vector>
using namespace std;
vector<int> calc_price(vector<int>& sales, const vector<vector<int>>& users, const vector<int>& emoticons)
{
int plus = 0, total_price = 0;
for (const vector<int>& user : users)
{
int buyable = user[0];
int plusable = user[1];
int buyable_price = 0;
for (int i = 0; i < emoticons.size(); ++i)
{
buyable_price += (sales[i] >= buyable ? emoticons[i] * (100-sales[i]) / 100 : 0);
}
if (buyable_price >= plusable) ++plus;
else total_price += buyable_price;
}
return {plus, total_price};
}
vector<int> find_best_sales(vector<int>& sales, int index, const vector<vector<int>>& users, const vector<int>& emoticons)
{
if (index >= emoticons.size())
{
return calc_price(sales, users, emoticons);
}
vector<int> best = {0, 0};
for (int sale : {10, 20, 30, 40})
{
sales[index] = sale;
vector<int> price = find_best_sales(sales, index+1, users, emoticons);
if (best[0] < price[0]) best = price;
if (best[0] == price[0] && best[1] < price[1]) best = price;
}
return best;
}
vector<int> solution(vector<vector<int>> users, vector<int> emoticons)
{
vector<int> sales(emoticons.size());
vector<int> best_price = find_best_sales(sales, 0, users, emoticons);
return best_price;
} | true |
2f48b172d50792df810b52fddfcee9a9e56c77f1 | C++ | CastBart/All-Projects | /Speed Souls Supreme/src/gui/GUI.cpp | UTF-8 | 10,003 | 3.046875 | 3 | [] | no_license | #include "gui\GUI.h"
/// <summary>
/// @brief Constructor of the GUI.
///
///
/// </summary>
/// <param name="controller">the controller to use</param>
/// <param name="checkboxTexture">texture to use for the checkbox</param>
GUI::GUI(std::shared_ptr<Xbox360Controller> controller, bool stripDraw)
: m_layoutNr(0)
, m_controller(controller)
, m_drawStrip(stripDraw)
, m_selectedWidget(nullptr)
{
if (m_drawStrip) //if we are drawing the strip then set it up
{
m_rectangleStrip = sf::RectangleShape(sf::Vector2f(500.0f, 1000.0f));
m_rectangleStrip.setPosition(400.0f, 300.0f);
m_rectangleStrip.setFillColor(sf::Color(250.0f, 50.0f, 0.0f, 100.0f));
m_rectangleStrip.setOutlineColor(sf::Color(255.0f, 255.0f, 0.0f, 100.0f));
m_rectangleStrip.setOutlineThickness(2.0f);
m_rectangleStrip.setOrigin(sf::Vector2f(m_rectangleStrip.getLocalBounds().width / 2, m_rectangleStrip.getLocalBounds().height / 2));
}
}
/// <summary>
/// @brief GUI destructor.
///
///
/// </summary>
GUI::~GUI()
{
}
/// <summary>
/// @brief Update all GUI elements.
///
///
/// </summary>
/// <param name="dt">represents time between frames</param>
void GUI::update(float dt)
{
if (m_selectedWidget != nullptr)
{
processInput();
m_selectedWidget->getFocus();
}
for (auto & widget : m_widgets)
{
if (m_widgets.size() <= 0 || widget->processInput(*m_controller))
{
break;
}
widget->update(dt);
}
}
/// <summary>
/// @brief Draw all widgets to screen.
///
///
/// </summary>
/// <param name="window">window target of all draw calls</param>
/// <param name="rendState">render states</param>
void GUI::draw(sf::RenderTarget& window, sf::RenderStates rendState) const
{
if (m_drawStrip)
{
window.draw(m_rectangleStrip, rendState);
}
for (auto & widget : m_widgets)
{
widget->draw(window, rendState);
}
}
/// <summary>
/// @brief Configures the GUI layout.
///
/// if Custom the layout remains unchanged
/// , if StackVertically the layout takes all non label widgets
/// and lays them out in the x-axis-center and evenly stacked on the y-axis
/// , if StripDiagonal the layout takes all non label widgets
/// and lays them out diagonally stacked
/// </summary>
/// <param name="layout">defines the type of layout</param>
void GUI::configure(const Layouts & layout)
{
sf::Vector2f screen(800.0f, 600.0f);
sf::Vector2f margin(m_screenMargin);
sf::Vector2f grid(0.0f, 0.0f);
sf::Vector2f offset(0.0f, 0.0f);
sf::Vector2f position(0.0f, 0.0f);
switch (layout)
{
case Layouts::StackVertically:
screen -= (margin * 2.0f);
grid = sf::Vector2f(0.0f, screen.y / static_cast<float>(m_layoutNr));
offset = sf::Vector2f(screen.x / 2.0f, grid.y / 2.0f) + margin;
break;
case Layouts::StripDiagonal:
screen -= (margin * 2.0f);
grid = (screen / static_cast<float>(m_layoutNr));
offset = (grid / 2.0f) + margin;
m_rectangleStrip.rotate(-60.0f);
break;
case Layouts::Custom:
default:
return;
break;
}
int j = 0;
for (unsigned i = 0u; i < m_widgets.size(); i++)
{
std::shared_ptr<Button> pButton;
std::shared_ptr<Slider> pSlider;
std::shared_ptr<CheckBox> pCheckBox;
auto& widget = m_widgets[i];
position = offset + (grid * static_cast<float>(j));
if (typeid(*widget) == typeid(Slider))
{
pSlider = std::dynamic_pointer_cast<Slider>(widget);
pSlider->setPosition(position);
j++;
}
else if (typeid(*widget) == typeid(Button))
{
pButton = std::dynamic_pointer_cast<Button>(widget);
pButton->setPosition(position);
j++;
}
else if (typeid(*widget) == typeid(CheckBox))
{
pCheckBox = std::dynamic_pointer_cast<CheckBox>(widget);
pCheckBox->setPosition(position);
j++;
}
}
}
/// <summary>
/// @brief Adds in a label.
///
/// takes in the parameters needed for a label
/// </summary>
/// <param name="contents">what label displays to the screen</param>
/// <param name="fontSize">size of each character</param>
/// <param name="position">position that label is centered on</param>
/// <param name="font">reference to loaded font needed for label drawing</param>
/// <param name="color">color of label (defaulted to white)</param>
void GUI::addLabel( sf::String contents
, unsigned int fontSize
, sf::Vector2f position
, sf::Font & font
, sf::Color color)
{
m_widgets.push_back(std::make_shared<Label>(contents,fontSize,position,font, color));
}
/// <summary>
/// @brief Adds a button to the GUI.
///
/// takes in params for a button
/// </summary>
/// <param name="message">Message to display on the button</param>
/// <param name="position">the centre of the button</param>
/// <param name="font">font to use for label</param>
/// <param name="fontSize">size of the font</param>
/// <param name="texture">texture of the button</param>
/// <param name="leftTextRect">texture rectangle for left edge of the button</param>
/// <param name="middleTextRect">texture rectangle for the middle section of button</param>
/// <param name="rightTextRect">texture rectangle for the right edge of the button</param>
void GUI::addButton( std::function<void()> function
, sf::String message
, sf::Vector2f position
, sf::Font & font
, unsigned int fontSize
, sf::Texture & texture
, sf::IntRect leftTextRect
, sf::IntRect middleTextRect
, sf::IntRect rightTextRect)
{
m_widgets.push_back(std::make_shared<Button>(
function
, message
, position
, font
, fontSize
, texture
, leftTextRect
, middleTextRect
, rightTextRect));
m_layoutNr++;
linkWidget();
}
/// <summary>
/// @brief Add a new slider to the GUI widget vector.
///
///
/// </summary>
/// <param name="font">the font of labels</param>
/// <param name="name">name of label</param>
/// <param name="fontSize">font size</param>
/// <param name="position">position of name label</param>
/// <param name="startingPos">starting position of slider</param>
/// <param name="sliderWidth">slider width</param>
/// <param name="sliderHeight">slider height</param>
/// <param name="minValue">minimum value</param>
/// <param name="maxValue">maximum value</param>
/// <param name="currentValue">current slider value</param>
void GUI::addSlider( sf::Font & font
, sf::String name
, unsigned int fontSize
, sf::Vector2f position
, float sliderWidth
, float sliderHeight
, float minValue
, float maxValue
, float& currentValue
, sf::Texture & texture
, sf::IntRect emptyTextRect
, sf::IntRect filledTextRect
, sf::IntRect squareTextRect)
{
m_widgets.push_back(std::make_shared<Slider>(texture, emptyTextRect, filledTextRect, squareTextRect, font, name, fontSize, position, sliderWidth, sliderHeight, minValue, maxValue, currentValue));
m_layoutNr++;
linkWidget();
}
/// <summary>
/// @brief Add a new checkbox to the GUI widget vector.
///
///
/// </summary>
/// <param name="font">font of label</param>
/// <param name="name">contents of label</param>
/// <param name="position">position of checkbox (center)</param>
/// <param name="scale">scale of the checkbox sprite</param>
/// <param name="onTexture">the on texture</param>
/// <param name="offTexture">the off texture</param>
/// <param name="state">current checkbox state (true = on/ false = off)</param>
/// <param name="charSize">the size of characters</param>
void GUI::addCheckbox( sf::Font & font
, sf::String name
, sf::Vector2f position
, float scale
, sf::Texture & texture
, sf::IntRect textRectOn
, sf::IntRect textRectOff
, bool & state
, unsigned charSize)
{
m_widgets.push_back(std::make_shared<CheckBox>(font, name, position, scale, texture, textRectOn, textRectOff, state, charSize));
m_layoutNr++;
linkWidget();
}
void GUI::clear()
{
m_selectedWidget = nullptr;
m_layoutNr = 0;
m_widgets.clear();
}
/// <summary>
/// @brief Links the passed vector iterator.
///
///
/// </summary>
void GUI::linkWidget()
{
// check that there is more than 1 eligible widget in the vector
if (m_layoutNr > 1)
{
// end iterator that goes to the last element of our widgets
auto endIterator = --m_widgets.end();
// copied iterator from the last element of our widgets
auto iterator = endIterator;
// go back to the 2nd last element of our widgets
iterator--;
// check that we dont hit the 1st element and
// check that we skip labels in the linking process
while (iterator != m_widgets.begin() && typeid(*(*iterator)) == typeid(Label))
{
// go back to the previous element
iterator--;
}
// set the last element of our widgets to
// to have their previous pointer set to the
// previous eligible element of the iterator
endIterator->get()->m_previous = (*iterator);
// set the previous eligible element of our widgets to
// have their next pointer set to the
// last element of our widgets
iterator->get()->m_next = (*endIterator);
}
if (m_selectedWidget == nullptr)
{
auto lastElement = --m_widgets.end();
if (typeid(*(*lastElement)) != typeid(Label))
{
m_selectedWidget = *lastElement;
}
}
}
/// <summary>
/// @brief Process xbox controller navigational input.
///
///
/// </summary>
void GUI::processInput()
{
const float& JOYSTICK_THRESHOLD = 50.0f;
if (
(m_controller->m_currentState.m_dpadUp && !m_controller->m_previousState.m_dpadUp)
|| (m_controller->m_currentState.m_lTS.y < -JOYSTICK_THRESHOLD && m_controller->m_previousState.m_lTS.y >= -JOYSTICK_THRESHOLD)
)
{
if (!m_selectedWidget->m_previous.expired())
{
m_selectedWidget->loseFocus();
m_selectedWidget = m_selectedWidget->m_previous.lock();
}
}
if (
(m_controller->m_currentState.m_dpadDown && !m_controller->m_previousState.m_dpadDown)
|| (m_controller->m_currentState.m_lTS.y > JOYSTICK_THRESHOLD && m_controller->m_previousState.m_lTS.y <= JOYSTICK_THRESHOLD)
)
{
if (!m_selectedWidget->m_next.expired())
{
m_selectedWidget->loseFocus();
m_selectedWidget = m_selectedWidget->m_next.lock();
}
}
}
| true |
e5246e38e834f632096a6b72e8b011703ba8b87a | C++ | NTUHEP-Tstar/ManagerUtils | /RootMgr/interface/HistMgr.hpp | UTF-8 | 1,956 | 2.53125 | 3 | [
"MIT"
] | permissive | /*******************************************************************************
*
* Filename : HistMgr
* Description : Class for Histogram management, uses Named class unque ID
* Author : Yi-Mu "Enoch" Chen [ ensc@hep1.phys.ntu.edu.tw ]
*
*******************************************************************************/
#ifndef MANAGERUTILS_ROOTMGR_HISTMGR_HPP
#define MANAGERUTILS_ROOTMGR_HISTMGR_HPP
#include "ManagerUtils/Common/interface/Named.hpp"
#include "ManagerUtils/RootMgr/interface/RootObjMgr.hpp"
#include "TH1D.h"
#include <string>
namespace mgr {
class HistMgr : public virtual Named
{
public:
HistMgr( const std::string& ); // Must have unique name
virtual
~HistMgr ();
// Explicitly removing copy constructor
HistMgr( const HistMgr& ) = delete;
HistMgr& operator=( const HistMgr& ) = delete;
TH1D* Hist( const std::string& );
const TH1D* Hist( const std::string& ) const;
std::vector<std::string> AvailableHistList() const;
void Scale( const double );
void SetColor( const Color_t );
void SetLineColor( const Color_t );
void SetFillColor( const Color_t );
void SetFillStyle( const Style_t );
void LoadFromFile( const std::string& );
void SaveToFile( const std::string& );
// Static functions for helping with title creation
static std::string MakeYTitle(
const double binwidth,
const std::string& xunit,
const unsigned exponent );
static std::string GetXUnit( const TH1D* );
static unsigned GetExponent( const double );
protected:
void AddHist(
const std::string& name,
const std::string& x_label,
const std::string& x_unit,
const int bin_size,
const double x_min,
const double x_max
);
private:
RootObjMgr<TH1D> _histmgr;
};
};
#endif/* end of include guard: MANAGERUTILS_HISTMGR_HISTMGR_HPP */
| true |
8fe5c7d82f338cc2ecb53cc40ee0bbf5e4d62e35 | C++ | 5dddddo/C-language | /자료구조/자구조HW1/linkedlist.cpp | UHC | 6,608 | 3.625 | 4 | [] | no_license | #include <iostream>
using namespace std;
#include <assert.h>
#include <malloc.h>
#include "linkedlist.h"
#include <string>
void create(LinkedList *lp)
{
lp->head = (Node *)calloc(1, sizeof(Node)); //Head Node
lp->tail = (Node *)calloc(1, sizeof(Node)); //Tail Node
lp->head->next = lp->tail; //Head next -> Tail prev
lp->tail->prev = lp->head; //Tail prev -> Head next
lp->head->prev = lp->head; //Head prev -> Head ڽ
lp->tail->next = lp->tail; //Tail next -> Tail ڽ
lp->cur = NULL;
lp->length = 0;
return;
}
Node *makeNode(DataType *dataPtr, Node *prev, Node *next)
{
Node *np;
np = (Node *)calloc(1, sizeof(Node));
if (np == NULL) return np; //Ҵ н 0 return
np->prev = prev; // tail prev np prev
np->next = next; // tail next np next
np->prev->next = np; // node node Ű
np->next->prev = np; //tail prev node next Ű
np->data = *dataPtr; //np data ü (ʱȭ)
return np;
}
Node *appendFromTail(LinkedList *lp, DataType *dataPtr)
{
lp->cur = makeNode(dataPtr, lp->tail->prev, lp->tail); // ( ,prev,next)
// : ּ return, : NULL return
if (lp->cur != NULL) lp->length++; //Ҵ length 1
return lp->cur;
}
void display(LinkedList *lp, void(*print)(DataType *))
{
lp->cur = lp->head->next; //#1. cur ù Ű
while (lp->cur != lp->tail)
{
print(&lp->cur->data);
lp->cur = lp->cur->next; //#2. ̵Ŵ
}
return;
}
void deleteNode(LinkedList *lp, Node *(&target))
{
target->prev->next = target->next;
target->next->prev = target->prev;
free(target);
lp->length--;
return;
}
Node *searchUnique(LinkedList *lp, string newData)
{
int lenW, lenN = newData.length();
lp->cur = lp->head->next; //#1. cur ù Ű
while (lp->cur != lp->tail)
{
lenW = lp->cur->data.getSearchword().length();
if (lenW == lenN)
{
if (lp->cur->data.getSearchword() == newData)
return lp->cur;
}
else
{
if (lp->cur->data.getSearchword().find(newData) != string::npos)
return lp->cur;
}
lp->cur = lp->cur->next; //#2. ̵Ŵ
}
return NULL;
}
Node * searchDuplicate(LinkedList *lp, string newDate, string newInfo)
{
LinkedList findList;
create(&findList);
int lenOld, lenI, lenD = newDate.length();
lp->cur = lp->head->next; //#1. cur ù Ű
while (lp->cur != lp->tail)
{
lenOld = lp->cur->data.getDate().length();
if (lenOld == lenD)
{
if (lp->cur->data.getDate() == newDate)
appendFromTail(&findList, &lp->cur->data);
}
else
{
if (lp->cur->data.getDate().find(newDate) != string::npos)
appendFromTail(&findList, &lp->cur->data);
}
lp->cur = lp->cur->next; //#2. ̵Ŵ
}
//display(&findList, printText);
lenI = newInfo.length();
findList.cur = findList.head->next; //#1. cur ù Ű
while (findList.cur != findList.tail)
{
lenOld = findList.cur->data.getInformation().length();
if (lenOld == lenI)
{
if (findList.cur->data.getInformation() == newInfo)
return findList.cur;
}
else
{
if (findList.cur->data.getInformation().find(newInfo) != string::npos)
return findList.cur;
}
findList.cur = findList.cur->next; //#2. ̵Ŵ
}
return NULL;
}
void insertionSort(LinkedList *lp)
{
Node *key = lp->head->next->next->next, *insertPos = key->prev;
DataType tmp;
while (insertPos != lp->tail)
{
lp->cur = insertPos->prev;
while (lp->cur != lp->head)
{
if (insertPos->data.getFrequency() > lp->cur->data.getFrequency())
{
tmp = insertPos->data;
insertPos->data = lp->cur->data;
lp->cur->data = tmp;
}
insertPos = insertPos->prev;
lp->cur = lp->cur->prev;
}
insertPos = key;
key = key->next;
}
}
//void bubbleSort(LinkedList *lp)
//{
// Node *key, *sorted;
// DataType temp;
// int i;
// lp->cur = lp->head->next;
// key = lp->cur->next;
// sorted = lp->tail;
// cout << "\n < Bubble Sort List >\n" << endl;
// while (sorted != lp->head->next)
// {
// lp->cur = lp->head->next;
// key = lp->cur->next;
// while (lp->cur != sorted)
// {
// if (lp->cur->data.getFrequency() < key->data.getFrequency())
// {
// temp = key->data;
// key->data = lp->cur->data;
// lp->cur->data = temp;
// }
// lp->cur = lp->cur->next;
// key = lp->cur->next;
// }
// sorted = sorted->prev;
// }
//}
Node* partition(LinkedList *lp, Node *first, Node *last)
{
Node* lastSmall(first), *i;
for (i = first->next; i != last->next; i = i->next)
{ // loop invariant: a[first+1]...a[lastSmall] <= a[first] &&
// a[lastSmall+1]...a[i-1] > a[first]
if (i->data.getFrequency() <= first->data.getFrequency()) { // key comparison
last = lastSmall->next;
swapElements(lp, lastSmall, i);
}
}
swapElements(lp, first, lastSmall); //z put pivot into correct position
// postcondition: a[first]...a[lastSmall-1] <= a[lastSmall] &&
// a[lastSmall+1]...a[last] > a[lastSmall]
return lastSmall; // this is the final position of the pivot -- the split index
}
void quicksort(LinkedList *lp, Node *first, Node *last)
{
// precondition: a is an array;
// The portion to be sorted runs from index first to index last inclusive.
if (first == last) // Base Case -- nothing to sort, so just return
return;
// Otherwise, were in the recursive case.
// The partition function uses the item in a[first] as the pivot
// and returns the position of the pivot -- split -- after the partition.
Node *split(partition(lp, first, last));
// Recursively, sort the two partitions.
quicksort(lp, first, split->prev);
quicksort(lp, split->next, last);
// postcondition: a is sorted in ascending order
// between first and last inclusive.
}
void swapElements(LinkedList *lp, Node *first, Node *i)
{
DataType tmp;
tmp = first->data;
first->data = i->data;
i->data = tmp;
}
void destroy(LinkedList *lp)
{
Node *tp;
lp->cur = lp->head->next;
while (lp->cur != lp->tail)
{
tp = lp->cur->next;
free(lp->cur);
lp->cur = tp;
}
free(lp->head);
free(lp->tail);
return;
}
void printText(DataType *p)
{
cout << "SearchWord : " << p->getSearchword() << "\nFrequency : " << p->getFrequency()
<< "\nDate : " << p->getDate() << "\nWebsite : " << p->getWebsite()
<< "\nInformation : " << p->getInformation() << endl;
cout << "--------------------------------------------------------------------------------" << endl;
} | true |
89ce36fc400518b69e1def555bdc8571609ee0af | C++ | Dzzirt/OOP | /Application/Application/ApplicationView.cpp | UTF-8 | 1,446 | 2.546875 | 3 | [] | no_license | #include "ApplicationView.h"
#include "iostream"
ApplicationView::ApplicationView()
{
m_workspace = std::make_shared<Workspace>(sf::Vector2f((WindowWidth - 640) / 2.f, 100), sf::Vector2f(640, 480));
m_toolbar = Toolbar(sf::Vector2f(0, 15), sf::Vector2f(float(WindowWidth), 40.f));
m_toolbar.AddButton(std::make_shared<CImageButton>("Assets/Rectangle.png", "Rectangle"));
m_toolbar.AddButton(std::make_shared<CImageButton>("Assets/Triangle.png", "Triangle"));
m_toolbar.AddButton(std::make_shared<CImageButton>("Assets/Ellipse.png", "Ellipse"));
m_toolbar.AddButton(std::make_shared<CImageButton>("Assets/Undo.png", "Undo"));
m_toolbar.AddButton(std::make_shared<CImageButton>("Assets/Redo.png", "Redo"));
}
void ApplicationView::Draw(sf::RenderWindow & window)
{
window.clear(sf::Color(238 ,238, 242));
m_toolbar.Draw(window);
m_workspace->Draw(window);
m_frame.Draw(window);
window.display();
}
//Chain of responsibility
//Events Interface
void ApplicationView::ProcessVisualEvents(const sf::Event & event, sf::RenderWindow & window)
{
if (!m_toolbar.ProcessVisualEvents(event, window))
{
if (!m_frame.ProcessEvents(event, window))
{
m_workspace->ProcessEvents(event, window);
}
}
}
Toolbar & ApplicationView::GetToolbar()
{
return m_toolbar;
}
Workspace & ApplicationView::GetWorkspace()
{
return *m_workspace;
}
Frame & ApplicationView::GetFrame()
{
return m_frame;
}
ApplicationView::~ApplicationView()
{
}
| true |