double zuida(std::vector<double> vec) {
std::vector<double> temp;
for(int i = 0; i < vec.size(); i++)
temp.push_back(vec[i]);
notend:
if(temp.size() > 0) {
if(temp.size() < 2) {
double tmp = *(&temp[0]);
return tmp;
}
else if(temp.size() >= 2) {
double mini = temp[0];
int ind = 0;
for(int i = 0; i < temp.size(); i++)
if(temp[i] < mini) {
mini = temp[i];
ind = i;
}
temp.erase(temp.begin() + ind);
goto notend;
}
}
}
The beauty is that every case is the best (also worst) case!
bool vlNoExitIfZeroBytesReceived = false; // false: can exit when receive 0 later; 1: can not exit when receive 0 later;
int getChar(char charachter){
int returnValue = Z;
switch(charachter){
case 'A': returnValue = A; break;
case 'a': returnValue = A; break;
case 'B': returnValue = B; break;
case 'b': returnValue = B; break;
case 'C': returnValue = C; break;
case 'c': returnValue = C; break;
case 'D': returnValue = D; break;
case 'd': returnValue = D; break;
case 'E': returnValue = E; break;
case 'e': returnValue = E; break;
case 'F': returnValue = F; break;
case 'f': returnValue = F; break;
case 'G': returnValue = G; break;
case 'g': returnValue = G; break;
case 'H': returnValue = H; break;
case 'h': returnValue = H; break;
case 'I': returnValue = I; break;
case 'i': returnValue = I; break;
case 'J': returnValue = J; break;
case 'j': returnValue = J; break;
case 'K': returnValue = K; break;
case 'k': returnValue = K; break;
case 'L': returnValue = L; break;
case 'l': returnValue = L; break;
case 'M': returnValue = M; break;
case 'm': returnValue = M; break;
case 'N': returnValue = N; break;
case 'n': returnValue = N; break;
case 'O': returnValue = O; break;
case 'o': returnValue = O; break;
case 'P': returnValue = P; break;
case 'p': returnValue = P; break;
case 'Q': returnValue = Q; break;
case 'q': returnValue = Q; break;
case 'R': returnValue = R; break;
case 'r': returnValue = R; break;
case 'S': returnValue = S; break;
case 's': returnValue = S; break;
case 'T': returnValue = T; break;
case 't': returnValue = T; break;
case 'U': returnValue = U; break;
case 'u': returnValue = U; break;
case 'V': returnValue = V; break;
case 'v': returnValue = V; break;
case 'W': returnValue = W; break;
case 'w': returnValue = W; break;
case 'X': returnValue = X; break;
case 'x': returnValue = X; break;
case 'Y': returnValue = Y; break;
case 'y': returnValue = Y; break;
case 'Z': returnValue = Z; break;
case 'z': returnValue = Z; break;
case ' ': returnValue = _; break;
case '3': returnValue = B2; break;
case '<': returnValue = TEMP; break;
case '*': returnValue = FULL; break;
case '|': returnValue = LINE; break;
case '_': returnValue = _; break;
case ':': returnValue = COL; break;
case '-': returnValue = DASH; break;
case ')': returnValue = BRA2; break;
case '%': returnValue = SMILE; break;
case '.': returnValue = DOT; break;
case '^': returnValue = COLDOT; break;
}
return returnValue; //RETORNO DE INFORMAÇÃO
}
found on brazillian website
ierr = pxmlIn->GetData(pcTag, *pTData);
*pbDataValid = bool((ierr==0)&&(iLen>0)); // enabled if: not empty string and vaild (number?)
if (*pbDataValid) iErr += ierr;
if ((&inactiveSlot)->GetFirstSlot() == RuntimeLib::INVALID_SLOT) {
Dot dude...
void winner(int score[4])
{
if (score[0] > score[1] > score[2] > score[3])
cout << "The winner is the Player 1 with " << score[0] << " points.";
else if (score[1] > score[0] > score[2] > score[3])
cout << "The winner is the Player 2 with " << score[1] << " points.";
else if (score[2] > score[0] > score[1] > score[3])
cout << "The winner is the Player 3 with " << score[2] << " points.";
else if (score[3] > score[2] > score[1] > score[0])
cout << "The winner is the Player 4 with " << score[3] << " points.";
}
int file_exist(){
FILE *file;
if((file = fopen(SCORE_FILE_NAME, "r"))){
fclose(file);
return 1;
}
return 0;
}
void SummonCrowd()
{
if(!bSummoned1)
{
if (Creature* Witness1 = me->SummonCreature(NPC_LISTENER,-11009.036f, 1490.47f, 43.58f, 4.16f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness2 = me->SummonCreature(NPC_LISTENER,-11010.76f, 1488.21f, 43.57f, 4.33f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness3 = me->SummonCreature(NPC_LISTENER,-11017.39f, 1491.76f, 43.19f, 4.78f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness4 = me->SummonCreature(NPC_LISTENER,-11021.73f, 1493.054f, 43.184f, 5.09f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness5 = me->SummonCreature(NPC_LISTENER,-11025.74f, 1487.70f, 43.17f, 5.45f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness6 = me->SummonCreature(NPC_LISTENER,-11025.25f, 1482.23f, 43.03f, 6.04f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness7 = me->SummonCreature(NPC_LISTENER,-11029.68f, 1481.255f, 43.185f, 6.20f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness8 = me->SummonCreature(NPC_LISTENER,-11024.46f, 1473.88f, 43.02f, 0.43f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness9 = me->SummonCreature(NPC_LISTENER,-11019.49f, 1471.70f, 43.21f, 1.09f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness10 = me->SummonCreature(NPC_LISTENER,-11021.56f, 1497.053f, 43.20f, 5.00f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness11 = me->SummonCreature(NPC_LISTENER,-11012.29f, 1488.14f, 43.77f, 4.16f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness12 = me->SummonCreature(NPC_LISTENER,-11014.67f, 1493.14f, 43.23f, 4.60f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness13 = me->SummonCreature(NPC_LISTENER,-11019.8f, 1494.25f, 43.2f, 4.77f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness14 = me->SummonCreature(NPC_LISTENER,-11023.6f, 1489.35f, 43.17f, 4.77f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness15 = me->SummonCreature(NPC_LISTENER,-11023.1f, 1482.51f, 43.07f, 6.25f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness16 = me->SummonCreature(NPC_LISTENER,-11027.2f, 1494.37f, 43.17f, 5.15f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness17 = me->SummonCreature(NPC_LISTENER,-11029.6f, 1488.29f, 43.19f, 5.64f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness18 = me->SummonCreature(NPC_LISTENER,-11030.8f, 1485.13f, 43.31f, 5.94f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness19 = me->SummonCreature(NPC_LISTENER,-11026.2f, 1478.62f, 42.94f, 6.17f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness20 = me->SummonCreature(NPC_LISTENER,-11013.2f, 1497.81f, 43.31f, 4.44f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness21 = me->SummonCreature(NPC_LISTENER,-11011.6f, 1492.61f, 43.39f, 4.44f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness22 = me->SummonCreature(NPC_LISTENER,-11015.4f, 1489.06f, 43.28f, 4.73f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness23 = me->SummonCreature(NPC_LISTENER,-11020.2f, 1490.15f, 43.19f, 5.07f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness24 = me->SummonCreature(NPC_LISTENER,-11009.9f, 1483.52f, 44.06f, 3.88f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness25 = me->SummonCreature(NPC_LISTENER,-11020.1f, 1484.87f, 43.18f, 5.33f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness26 = me->SummonCreature(NPC_LISTENER,-11017.7f, 1487.42f, 43.24f, 4.89f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness27 = me->SummonCreature(NPC_LISTENER,-11017.9f, 1498.24f, 43.20f, 5.04f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
{
Witness1GUID = Witness1->GetGUID();
Witness2GUID = Witness2->GetGUID();
Witness3GUID = Witness3->GetGUID();
Witness4GUID = Witness4->GetGUID();
Witness5GUID = Witness5->GetGUID();
Witness6GUID = Witness6->GetGUID();
Witness7GUID = Witness7->GetGUID();
Witness8GUID = Witness8->GetGUID();
Witness9GUID = Witness9->GetGUID();
Witness10GUID = Witness10->GetGUID();
Witness11GUID = Witness11->GetGUID();
Witness12GUID = Witness12->GetGUID();
Witness13GUID = Witness13->GetGUID();
Witness14GUID = Witness14->GetGUID();
Witness15GUID = Witness15->GetGUID();
Witness16GUID = Witness16->GetGUID();
Witness17GUID = Witness17->GetGUID();
Witness18GUID = Witness18->GetGUID();
Witness19GUID = Witness19->GetGUID();
Witness20GUID = Witness20->GetGUID();
Witness21GUID = Witness21->GetGUID();
Witness22GUID = Witness22->GetGUID();
Witness23GUID = Witness23->GetGUID();
Witness24GUID = Witness24->GetGUID();
Witness25GUID = Witness25->GetGUID();
Witness26GUID = Witness26->GetGUID();
Witness27GUID = Witness27->GetGUID();
bSummoned1 = true;
}
}
}
if(!Hardware::initialize()) {
Serial.println("Hardware initialization failed!");
for(;;){}
}
if(!UI.begin()) {
Serial.println("SSD1306 allocation failed");
for(;;){}
}
For is best ever, why even bother with While, or even Return... Source of code: https://github.com/MausTec/nogasm-wifi/blob/master/ESP32_WiFi.ino
if(!strncmp(pcTagName,strlim,(int)strlen(strlim))) return "";
char * dataFunc(){
TCHAR tc[256];
LONG tc_len = sizeof(tc);
getData((LPBYTE)&tc, &tc_len);
char * data = new char[tc_len];
for(int i = 0;i < tc_len;i++)
data[i] = tc[i];
return data;
}
#include <iostream>
#define OPEN_PARENTHESIS (
#define CLOSE_PARENTHESIS )
#define OPEN_BRACES {
#define CLOSE_BRACES }
#define INTEGER int
#define STANDARD_LIB std::
#define CONSOLE_OUT cout
#define ANGLE_BRACKETS <<
#define MESSAGE "Hello World\n"
#define SEMI ;
#define CLASS_NAME main
INTEGER CLASS_NAME OPEN_PARENTHESIS CLOSE_PARENTHESIS OPEN_BRACES
STANDARD_LIB CONSOLE_OUT ANGLE_BRACKETS MESSAGE SEMI
CLOSE_BRACES
Everything is defined
#define private public
#define protected public
#define class struct
#include "your_private_parts.hpp"
// ...
#undef class
#undef protected
#undef private
// ...
Fails miserably if template <class>
, template <template <class> class>
or their variations are found anywhere inside your header.
:(
for (int i = 0;i < n / 2;i++)
{
while (num[a[p].id].n == 0 || num[num[a[p].id].nxt].n == 0)
{
p++;
}
printf("%d %d ", num[a[p].id].n, num[num[a[p].id].nxt].n);
num[a[p].id].n = 0;
num[num[a[p].id].nxt].n = 0;
num[num[a[p].id].lst].nxt = num[num[a[p].id].nxt].nxt;
num[num[num[a[p].id].nxt].nxt].lst = num[a[p].id].lst;
}
// Test read access of memory
try
{
c = ( (char*) pvMemory )[0];
c = ( (char*) pvMemory )[iNLen - 1];
}
catch( ... ) {
return -1;
}