Forum: C++ 13 Hours Ago |
| Replies: 5 Views: 110 You don't have to manipulate the array after being sorted.
You can use a for loop to start from 1 to the array size to show the array. This would disclude the last element. Of course you need to... |
Forum: C++ 2 Days Ago |
| Replies: 7 Views: 197 |
Forum: C++ 2 Days Ago |
| Replies: 7 Views: 197 Is "it" a online judge? If so then post the question. |
Forum: C++ 2 Days Ago |
| Replies: 7 Views: 168 Ok then.
Here are some tips.
1) Whenever you have "new" keyword used, match it with a "delete"
keyword. Make sure there is a 1 to 1 relationship there.
2) Instead of raw pointers, use... |
Forum: C++ 2 Days Ago |
| Replies: 7 Views: 168 post your code and you will get more help |
Forum: Geeks' Lounge 3 Days Ago |
| Replies: 2 Views: 131 In what sense of "Marketing"? |
Forum: C++ 3 Days Ago |
| Replies: 3 Views: 121 using structs or classes would be easier and more elegant. What do
you think? |
Forum: C++ 4 Days Ago |
| Replies: 17 Views: 350 This shouldn't be this hard.
You want to read from a text file of the format :
Firstname;Lastname;178
where the ';' means the word has ended. And you know you will
always read firstname,... |
Forum: C++ 5 Days Ago |
| Replies: 5 Views: 158 >>This leaves my wondering if it would be possible to use -= to decrease after each loop in any way ?
Try it. Put Fr->callEvent -= Fr->callEvent after the call to Dt->eventHandler. |
Forum: C++ 5 Days Ago |
| Replies: 5 Views: 158 >>Is there a way to delete the content on the left side of += after each loop ?
Can't know for sure without knowing Fr->callEvent type, but
Assumming callEvent is a string ? You can just reset... |
Forum: C++ 6 Days Ago |
| Replies: 10 Views: 261 Change this :
if (num > largest)
largest = num;
count++;
to this :
if (num >= largest) { |
Forum: C++ 6 Days Ago |
| Replies: 9 Views: 295 Don't worry about that. Just do it with if statements.
For example to sort 2 variable you can do this :
int n = 0;
int m = 0;
cin >> n >> m;
if(n < m )
cout << n << " " << m; |
Forum: C++ 6 Days Ago |
| Replies: 7 Views: 216 Its not hard.
#include<fstream>
using namespace std;
int main()
{
ifstream readFromFile("test.txt");
string var1, var2;
readFromFile >> var1 >> var2 ; |
Forum: C++ 6 Days Ago |
| Replies: 7 Views: 216 read this (http://www.cplusplus.com/doc/tutorial/files/) |
Forum: Java 6 Days Ago |
| Replies: 5 Views: 224 |
Forum: C++ 6 Days Ago |
| Replies: 4 Views: 201 replace the && with the ||. You wan't the loop to run if either currentX OR currentY is not equal to toX or toY, respectively.
Also take out the
else { currentX-- } and else{ currentY-- }
... |
Forum: C++ 10 Days Ago |
| Replies: 5 Views: 201 How to use functions :
1) Declare a prototype .
Ex :
//int is the return type
//calculateBonus is the function's name
//int number is its argument
// the semicolon " ; " means its a... |
Forum: C++ 10 Days Ago |
| Replies: 9 Views: 295 Yep I guess, you can use if statements to sort this. |
Forum: C++ 11 Days Ago |
| Replies: 25 Views: 1,056 What have you really learned in the class so far, what concepts?
You haven't learned about functions or you don't want to use functions?
Can you use the standard functions?
Think of all... |
Forum: C++ 11 Days Ago |
| Replies: 25 Views: 1,056 In psuedocode of course :
void insertionSort(int * Array, int size)
{
//declare minElem variable to 0
//for i = 0 to i < size, increment i by 1
{ |
Forum: C++ 11 Days Ago |
| Replies: 25 Views: 1,056 well since since there are 5! possible combination, the minimum
number of if stated you will use is 2^5 = 32.
That will suck.
Just use insertion sort, the idea behind it is to mid a max*... |
Forum: C++ 12 Days Ago |
| Replies: 25 Views: 1,056 Yes, your if/else is incorrect, only 1 of them gets evaluated. |
Forum: C++ 13 Days Ago |
| Replies: 2 Views: 209 1) use Code tags.
2) The second one. Its more reusable. |
Forum: C++ 14 Days Ago |
| Replies: 7 Views: 267 >> but my teacher wants the user to be able to be able to input a number of any length
That means that you shouldn't use int, double , long long or whatever.
It means you should get your input as... |
Forum: C++ 14 Days Ago |
| Replies: 7 Views: 267 in your reverse function, what happens if num is less than 0?
What would the function return?
Get the input as a string and print the string backwards. Makes sure the string contains numeric data... |
Forum: C++ 15 Days Ago |
| Replies: 3 Views: 282 Have a test condition in your for loop.
In psuedocode :
for i = 0 untill MAX{
pick1 = random number
pick2 = random number
while(pick2 == pick1 ) pick2 = another random number
pick3 =... |
Forum: C++ 15 Days Ago |
| Replies: 4 Views: 353 They have given you the answer, but let me expand on that :
Your prototype for fillArray is this :
int fillArray(int);//Trying to make a fn that fills an array
What does that mean ? It says... |
Forum: C++ 17 Days Ago |
| Replies: 25 Views: 1,056 1) Why ?
2) need compile time variable meaning there will be a fixed amount
of inputs to get
3) Need to implement your own sorting method and use it inside main,
so technically it won't be a... |
Forum: C++ 17 Days Ago |
| Replies: 7 Views: 249 Think of main as a variable. And your function takes a variable a well.
But the variable is not normal, its a function. A function can be passed to another function like a variable. You just need... |
Forum: C++ 17 Days Ago |
| Replies: 7 Views: 249 How about you warp your code into code tags, correctly.
Then comment on each line of code, so we can see what you are thinking. |
Forum: C++ 18 Days Ago |
| Replies: 2 Views: 229 Input = cin
x is a float
y is a int
r is a int
for i to y means :
for(int i = 1; i < y; i++)
{
//code goes here |
Forum: C++ 20 Days Ago |
| Replies: 3 Views: 289 Here is a hint :
********** 10 stars
********* 9 stars
******** 8 stars
******* 7 stars
****** 6 stars
***** 5 stars
**** 4 stars
*** 3 stars |
Forum: C++ 25 Days Ago |
| Replies: 3 Views: 237 Use the suggestion above, although you might want to google sorting for knowledge experience.
You can do this if you want to use std::sort;
#
int main()
{
int x[5];
prompt(x);... |
Forum: C++ 27 Days Ago |
| Replies: 2 Views: 213 >>i not sure what is the single quote means...
Its usually used with char variables :
char quit = 'n';
if( quit == 'n' )
cout<<"Still playing\n"; |
Forum: C++ 27 Days Ago |
| Replies: 8 Views: 436 You forgot to enable GL_COLOR_MATERIAL, when using lighting. I
changed it a little, take a look at the comments.
#define GLUT_DISABLE_ATEXIT_HACK
#include <stdlib.h>
#include <GL/glut.h>
... |
Forum: C++ 27 Days Ago |
| Replies: 8 Views: 436 wanna send me the file so I can take a look at it. Make sure you
have enabled lighting and LIGHT0 |
Forum: C++ 29 Days Ago |
| Replies: 9 Views: 281 your function call should be :
values(value1); |
Forum: C++ 30 Days Ago |
| Replies: 10 Views: 656 Forgot to seed.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
srand(time(0)); |
Forum: C++ 30 Days Ago |
| Replies: 8 Views: 436 Did you call glNormalize in your init function ?
By having proper normals the light "reflects" of the shape and thus it works out as planned. If you don't calculate normals then your object ... |
Forum: C++ 30 Days Ago |
| Replies: 8 Views: 436 Its because you don't have your normals calculated for rectangles.
Plus put your lighting function in our initGL function. |