36 Posted Topics
Re: So I've been testing these algorithms, and really, they're SO slow >.<, I myself made a prime number calculator, when I needed to regenerate prime numbers for some RSA encryption, however, I used this program; It's able to find all the prime numbers from 3-50.000.000 in about 2½second. [CODE] #include … | |
Re: [QUOTE=sidra 100;1113291]hey how to clear the screen in c++ i m using dev c++. clrscr()doesnot work[/QUOTE] You could try; #include <windows.h> System("CLS"); // Not a good way to do it however, but gets the job done | |
Re: Something useful, a simple RSA encrypting application, with all that belongs, wrapped in some yellow paper is a safe bet :) | |
Okay, I'm making a shooter game, and all my weapons are differnt userdefined objects; ie. the flamethrower works differently then the gun, however, I'm calling some functions in my "main", an example of this would be; [CODE] /* <Init> */ MachineGunClass *CurrentWeapon; MachineGunClass *MachineGun; MachineGun = new MachineGunClass(); CurrentWeapon = … | |
Re: [QUOTE=jonsca;1123503]Yeah, I've been through that myself. I've never found a way around it.[/QUOTE] Google Code is able to do it, however Google itself, ignores punctation, as a rule of thumb! [url]http://www.google.com/codesearch?hl=en&sa=N&q=%22-%3E%22++lang:c&ct=rr&cs_r=lang:c[/url] | |
Re: [QUOTE=deorcar;1118636]... what im trying to do is to make a 2nd box or sprite that will follow the frist box ive made ...[/QUOTE] What do you mean by follow, like, should the second box, be following the first one, on movement, because you haven't implementated that yet? - Or do … | |
So I've got this program I made, and I wanted to speed it up, using multithreading, to make use of my quad core. The program itself fully supports multithreading. The problem is, that when I'm running the program, using just one; CreateThread() it finishes in 6seconds, if I run 2 … | |
So I'm working on this class, which is basically to wrap a char into 8bools, and it works so far, however I'm running into a problem, in the dedication of values, since I'm to use the overloaded array operator, as well as the overloaded assignment operator, at once, however I … | |
So I've been working on two small programs to calculate prime numbers, fast and memory efficiently. Both my algorithms are based upon the 'Sieve of Eratosthenes', and I know that the 'Sieve of Atkin' would be the way to go since its faster, however I'm just trying to optimize the … | |
So I'm working with OpenGL, and DevIL to load some JPEG into my program, and I've had some trouble, I've isolated the program in a simple sample program (uploaded), the program is, that when I load the standard file, that came with the guide ("Geeks3D.jpg") it loades instantly and runs … | |
So I'm working on this game, and I've been using "glaux.h" to load my textures, however I'm interrested in using JPEG's, so I found an example to do this on: [url]www.morrowland.com[/url], however, when I compile it (after fixing the errors), then I get this, on the linking state, any help … | |
Re: [QUOTE=CppBuilder2006;1095236]in Windows Task Manager --> Processes there is a list of running exe files. I am going to write a program that lists these running exe files. How can I obtain the list? I use Windows XP :$ & Windows API!:)[/QUOTE] Something like this? - Just an old program I … | |
So I'm quite new to c++, and I'm really into pointers, does anyone got like, an idea on how to really get to know pointers, assignments, tasks, tutorials, ect. Basically, my knowledge in C++, is classes, operator overloading, and like simple stuff, so if you're able to come up with … | |
Okay, I'm making a game, and I need to use random inside a class, however I can't figure out how to seed the randomness into the class, so atm I'm getting the same random each time. I've tried stuff like srand(time) in main, however, that doesn't apply to the class, … | |
I'm making this snake game, and I've created a class to handle the snakes (players and AI snakes), this works out quite well, however, at the moment I'm declaring my main snake (player 1), as global, in terms of: [CODE] class Snake { //... Lots and lots of code. } … | |
Re: [QUOTE=ziyakhan10;1077725]I am trying to write a program to find nearest prime to a number to its left...using for loop i just don't seem to get it right [CODE] #include<iostream.h> #include<conio.h> void main() { clrscr(); int n1,flag=0; cout<<"Enter The Number"<<endl; cin>>n1; for(int i=n1;i>0;i--) { for(int j=2;j<(i/2);j++) { if(i%j==0) { flag=0; } … | |
Re: Hey Mafia, I got about the same task some time ago, and I wrote my code using a bitwise buffer to store all uneven numbers from 3 till the entered number, and then by using 'The Sieve of Eratosthenes' to sort out the numbers, simply picking the first one, and … | |
Re: Try using a thread like this, and events to halt the thread: [CODE] #include <windows.h> #include <stdio.h> DWORD WINAPI myfunk(LPVOID input) // The actual Thread { HANDLE VENTE = (HANDLE) input; Sleep(1000); // Sleep for 1 sec SetEvent(VENTE); // Send a signal to main, asking it to go beyond the … | |
Re: Depens on when you're interrested in loading and closing it; but something like this: [CODE] for (int a=0; a<=10;a++) { if (a==0){LOAD} // Some stuff if (a==10){CLOSE} } [/CODE] Something like this? | |
Re: [QUOTE=xueyingkoo;1040162]i ony able do until tis step , since i really dont know how to apply the array on tat i understand wat u say the question just request smoking o non smoking but the lecturer say need to include those things , i force to do that ..i dont … | |
Re: [QUOTE=Campbel;1038750]just increment by 2 instead of one and print every number.. for(i=0; i<x; i=i+2)[/QUOTE] Like Campbel said, the following will do just that: [CODE] #include <iostream> // General Header #define POINT 10 // Max point to go to for the 'for loop' int main(){ // Main for (int i=0; i<=POINT; … | |
Re: [QUOTE=juniper2009;1035746]Thanks But still I dont get that how to read the lines(string) from an external file " file.txt" regards[/QUOTE] Here's a simple program on how to load the string into the program from a file; [CODE] #include <fstream> // Header File for File Reading #include <iostream> // Header File for … | |
Re: Use code tags please: [CODE] #include <iostream> using namespace std; void getData(double& input1, double& input2, double& input3, double& input4, double& input5); //Ask the user to input numbers void calcscore(double& num1, double& num2, double& num3, double& num4, double& num5); //should calculate and display the average of the 3 remaining numbers int … | |
Re: How about something like this? [CODE] #include <cstdlib> // Header for randomness #include <ctime> // Header for time (used to seed random) #include <iostream> // Header for general IO put using namespace std; int main() { bool done=false; while (!done) { srand(time(NULL)); // Seed random int CorrectAnswers=0,AnswersDone=0; while(1) { if … | |
Re: [QUOTE=Mohamad89;1027483]Hello, I am currently doing a research at my university about the ways in which we can use multicore CPU to enhance graphics performance instead of putting all the load on the GPU, I am trying to work with both OpenGL and OpenMP and I am planning on using gDebugger … | |
Re: Try taking a look on this thread: [url]http://www.daniweb.com/forums/thread235673.html[/url] Any luck there? | |
Re: If you want to encrypt something, why wouldn't you use like a simple RSA encryption? Somethin like this; [CODE] #include <iostream> #include <math.h> using namespace std; int main() { int M=0; //input number (unencrypted). int C; //output number (encrypted). unsigned long long calcul; //used to store calculations. int a=0; int … | |
I've been having some thought, like, if I run a program, and I'm exporting a pointer to a variable "a" to a file, and I reads that information with another program, wouldn't the second program be able to modify "a" in the first program using that pointer? - Like the … | |
Sorry for doing this, but anyone with GLUT experience willing to look though a little code, since it's not working at all; I posted the thread here: [url]http://www.daniweb.com/forums/thread235691.html[/url] | |
Re: The simplest way if your thinking about using loops, is using arrays to store the values; something like this: [CODE] #include <fstream> // Header File for File Reading #include <iostream> // Header File for General I/O-put using namespace std; // Use namespacing float x[10], y[10], z[10]; // floats for loaded … | |
Re: As Crazyboy says, use the following: [CODE] string str (ARRAYNAME); SomeLengthVar=str.length(); [/CODE] or simply use: [CODE] strlen(ARRAYNAME)); [/CODE] That's about the easiest way | |
So I'm working on this OpenGL 3D Graph program, and like, I ran into some trouble, since I wanted it to support fullscreen, so I made the following; [CODE] int main(int argc, char *argv[]) { ... // Some stuff glutSpecialFunc(SpecKey); ... // More stuff } [/CODE] Which is calling the … | |
Re: [QUOTE=UKmason;1035661] I know height = distance * tan(angle) - (gravity * distance^2) /2 *( speed * cos(angle))^2 [/QUOTE] Did you remember to use parentheses? height = (distance*(tan(angle)))-((gravity*(distance*distance))/(2*((speed*(cos(angle)))*(speed*(cos(angle)))))) Better to use too many parentheses then too few | |
Re: Don't kill me, but wouldn't you be able to slow down the process using like: Sleep(a); where "a" is the number of miliseconds to sleep, the function is declared in; "<windows.h>" And about your second question, then how about using a return? | |
Re: [CODE] for(int c=0;c<student_max;c++) { if(search_id==id[c]) { location=binary_search(id,student_max,search_id); cout<<"Student ID \tTotal \tGrade"<<endl; cout<<"-----------------------------"<<endl; cout<<search_id<<" \t\t"<<total[location]<<" \t"<<determine_grade(total[location])<<endl; } else { cout<<"Incorrect id entered"<<endl; } } [/CODE] As far as I'm able to see, the code is fine? | |
Re: First of all, I don't think that; "Void Main()" is ISO standard, I think you should stick to "Int Main()". Secondly you're redeclaring numbers in Main, after making it a global variable. Thirdly you're calling; "push(value);", which isn't really calling your own function, it's calling "push(const value_type& __x)" inside the … |
The End.