Instead of checking after you create the set of Xs, simply use std::set.
Hi there,i've been doing a little minigame which is about you moving a "0" around,having to hit randomly placed "X" scattered around the console.
However,if two or more of these variables have the same X and Y coords,then when "hitting" them you will just carry one of the two along with you,never winning.
So this is what i have to do:
I have to check if any of these two groups of variables a,b,c,d,e,f,g,h,i,j and z,x,c,v,b,n,m,j,k,l have at least 2 equal values OR if they are all different.
while atm i'd have to check if a is equal to any,if b is equal to any,if c is equal to any etc etc,i'd really like to know if there is another way to do this...as it takes a huge amount of space and time to write while it also takes a (relatively) long time to execute.
P.s. the values are from 2-80 and 2-25.
P.p.s. yep i already searched on the net but i could only find information about wether a string is composed of numbers or not -.-
Instead of checking after you create the set of Xs, simply use std::set.
Last edited by abuckau907; 11-06-2013 at 08:51 PM. Reason: supercalafragalisticexpialadoshus
'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
--
you could use vectors (because im guessing the amount of values shrinks and grows?) and iterator...i can help you more if you don't know how to do this.
use binary search instead of linear search. much faster
Let me google that for you
Yeah,atm i am supposed to know assignments,if,do/while...but i like going by my own.
In this case,i have 10 values which are "on the x axis" and 10 which are "on the y axis" and are used as coords to output a character,if you move your pointer over it,you gain score. (a very little game yup)
The issue is when two randomly generated coords are equal (same X1 and X2 while also same Y1 and Y2) as one X will be placed as it should be and se second,instead of overlapping it,is placed on the right...but when trying to hit them,the second will follow you and you can't win anymore.
:7
*edit*
I semi-fixed the code by adding a re-roll feature that resets the objectives position (still not a real fix).
Last edited by IV2B; 11-07-2013 at 08:32 AM.
Se ti serve aiuto chiedi pure
List Of My Public Releases
Wallhack and NoFog - Detected (https://www.mpgh.net/forum/164-combat...ml#post1391299)
BOSCHACK CA EU v1.0 - Detected (https://www.mpgh.net/forum/172-combat...eu-v1-0-a.html)
BOSCHACK CA EU v1.1 - Detected (https://www.mpgh.net/forum/172-combat...ml#post2371767)
BOSCHACK Returned - Detected (https://www.mpgh.net/forum/172-combat...eturn-pub.html)
Make Hacks In 5min in 3 Steps
Non conoscendo il codice, mi viene in mente solo utilizzare un'array di variabili COORD (sono strutture che hanno due attributi di tipo long: x e y). Così potresti fare un piccolo for e indicizzare l'array è più elegante da vedere ( e probabilmente anche più logico e facile ) però sempre lo stesso numero di if verranno fatti, solo che non li scrivi a mano xD
Se ho capito bene, qualcosa di simile:
Poi vedi tu se lo vuoi globale o noCode:COORD v[10]; bool Check() { for( int i = 0; i < (sizeof(v) / sizeof(COORD)) - 1; i++) if(v[i].X == v[i+1].X && v[i].Y == v[i+1].Y) return true; return false; }
Last edited by Sixx93; 11-17-2013 at 03:35 PM.
List Of My Public Releases
Wallhack and NoFog - Detected (https://www.mpgh.net/forum/164-combat...ml#post1391299)
BOSCHACK CA EU v1.0 - Detected (https://www.mpgh.net/forum/172-combat...eu-v1-0-a.html)
BOSCHACK CA EU v1.1 - Detected (https://www.mpgh.net/forum/172-combat...ml#post2371767)
BOSCHACK Returned - Detected (https://www.mpgh.net/forum/172-combat...eturn-pub.html)
Make Hacks In 5min in 3 Steps
No need to check afterwards when you can just generate unique instances (the container does the checking for you).Code:#include <iostream> #include <cstdlib> #include <ctime> #include <set> #include <utility> int main() { std::set<std::pair<unsigned int, unsigned int>> x_locations; std::srand(std::time(0)); while (x_locations.size() < 10) { unsigned int x = std::rand() % 79 + 2; unsigned int y = std::rand() % 24 + 2; x_locations.emplace(x, y); } for (auto x_loc : x_locations) std::cout << x_loc.first << ' ' << x_loc.second << std::endl; }
Edit: Misunderstood what you wanted but if you actually understand how to program you can reimplement this to work on two sets of coordinates to create unique coordinates.
Last edited by Fovea; 11-17-2013 at 05:23 PM.
Ora ho 20 variabili chiamate onex,oney,twox,twoy etc etc,questo è il codice:
Il problema è che in rari casi due coordinate equivalgono ad altre :/Code:srand ( time(NULL) ); onex= rand() % 79 + 2; twox= rand() % 79 + 2; threex= rand() % 79 + 2; fourx= rand() % 79 + 2; fivex= rand() % 79 + 2; sixx= rand() % 79 + 2; sevenx= rand() % 79 + 2; eightx= rand() % 79 + 2; ninex= rand() % 79 + 2; tenx= rand() % 79 + 2; oney=rand() % 23 + 2; twoy=rand() % 23 + 2; threey=rand() % 23 + 2; foury=rand() % 23 + 2; fivey=rand() % 23 + 2; sixy=rand() % 23 + 2; seveny=rand() % 23 + 2; eighty=rand() % 23 + 2; niney=rand() % 23 + 2; teny=rand() % 23 + 2;
Per utilizzare il tuo metodo dovrei stravolgere il programma x)
E ora ho "sistemato" con dei "reroll": se viene premuto tab il programma "re-rolla" le variabili.
BohBohBohBohBohBohBohBohBohBohBohBohBohBohBoh D:
Utilizzando così delle variabili indipendenti, veramente non mi viene in mente proprio nulla se non una marea infinita di if... il che è fattibile tanto quanto orribile xD a mio avviso, anche per avere un codice più organizzato, meglio adottare una soluzione simile a quella che ti ho proposto.
Anche perchè dopo, la randomizzazione delle coordinate ti viene veramente di 3 righe, una in più del controllo. Poi, vedi tu xD
Mi pare comunque di aver capito che questo programma è 4fun quindi può anche essere "alla buona" il codice, quindi... vedi tu xD
Edit:
O sennò, cambia il seme! dichiara un indice che ogni random aumenta di tot e lo usi come seme e lo reimposti sistematicamente. Sarà molto meno probabile avere coordinate uguali.
Last edited by Sixx93; 11-18-2013 at 06:34 AM.
List Of My Public Releases
Wallhack and NoFog - Detected (https://www.mpgh.net/forum/164-combat...ml#post1391299)
BOSCHACK CA EU v1.0 - Detected (https://www.mpgh.net/forum/172-combat...eu-v1-0-a.html)
BOSCHACK CA EU v1.1 - Detected (https://www.mpgh.net/forum/172-combat...ml#post2371767)
BOSCHACK Returned - Detected (https://www.mpgh.net/forum/172-combat...eturn-pub.html)
Make Hacks In 5min in 3 Steps