Click here to Skip to main content
15,900,378 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionPrinter Driver Pin
Ghasrfakhri11-Sep-05 9:27
Ghasrfakhri11-Sep-05 9:27 
Questionhow can I Create an Office plugin? Pin
Ghasrfakhri11-Sep-05 9:24
Ghasrfakhri11-Sep-05 9:24 
AnswerRe: how can I Create an Office plugin? Pin
ThiefXXX11-Sep-05 11:34
ThiefXXX11-Sep-05 11:34 
QuestionWebbrowser Pin
RaymondM11-Sep-05 9:15
RaymondM11-Sep-05 9:15 
QuestionC++ question Pin
Sveta8011-Sep-05 7:44
Sveta8011-Sep-05 7:44 
AnswerRe: C++ question Pin
Nemanja Trifunovic11-Sep-05 7:59
Nemanja Trifunovic11-Sep-05 7:59 
AnswerRe: C++ question Pin
PJ Arends11-Sep-05 9:52
professionalPJ Arends11-Sep-05 9:52 
GeneralRe: C++ question Pin
Sveta8011-Sep-05 10:36
Sveta8011-Sep-05 10:36 
This is a very helpful one. Thanks!!!
Here is what I have so far for the program that reads some (no one knows how many before hand) positive numbers (double) from teh stdin, sorts teh numbers and prints them in sorting orders (biggest number first). Whenever teh number is negative my code should start sort the numbers it already gets (except the negative) and print. I am thinking that it should work, but does anyone see any bugs?

#include <iostream>
#include <cstdlib>
using namespace std;

double *getDouble(int & numbersRead)
{
int arraySize = 0;
double inputVal;
double *array = NULL;

numbersRead = 0;
cout << "Enter any number of integers: ";
while( cin >> inputVal )
{
if(numbersRead == arraySize)
{
double *original = array;
array = new double [arraySize * 2 + 1];
for(int i = 0; i < arraySize; i++)
array[i] = original[i];
delete[]original;
arraySize = arraySize * 2 + 1;
}
array[numbersRead++] = inputVal;
}
return array;
}
int main()
{
double *array;
int size;
array = getDouble(size);
int last = size - 2;
int isChanged = 1;
while(last >= 0 && isChanged)
{
isChanged = 0;
for(int k = 0; k <= last; k++)
{
if(array[k] < array[k+1]
{
double temp;
temp = array[k];
array[k] = array[k+1];
array[k+1] = temp;
isChanged = 1;
}
last--;
}}
for(int i = 0; i < size; i++)
{
if(array[i] < 0)
cout << array[i] << endl;
}
return ;
}
GeneralRe: C++ question Pin
Marc Clifton11-Sep-05 12:09
mvaMarc Clifton11-Sep-05 12:09 
GeneralRe: C++ question Pin
PJ Arends11-Sep-05 12:35
professionalPJ Arends11-Sep-05 12:35 
GeneralRe: C++ question Pin
Marc Clifton11-Sep-05 13:48
mvaMarc Clifton11-Sep-05 13:48 
GeneralRe: C++ question Pin
PJ Arends11-Sep-05 19:28
professionalPJ Arends11-Sep-05 19:28 
GeneralRe: C++ question Pin
Christian Graus11-Sep-05 12:46
protectorChristian Graus11-Sep-05 12:46 
GeneralRe: C++ question Pin
Marc Clifton11-Sep-05 13:49
mvaMarc Clifton11-Sep-05 13:49 
GeneralRe: C++ question Pin
Christian Graus11-Sep-05 13:53
protectorChristian Graus11-Sep-05 13:53 
GeneralRe: C++ question Pin
Nemanja Trifunovic12-Sep-05 2:26
Nemanja Trifunovic12-Sep-05 2:26 
GeneralRe: C++ question Pin
Nemanja Trifunovic12-Sep-05 2:30
Nemanja Trifunovic12-Sep-05 2:30 
GeneralC++ question Pin
Sveta8011-Sep-05 7:32
Sveta8011-Sep-05 7:32 
GeneralRe: C++ question Pin
Trollslayer11-Sep-05 7:42
mentorTrollslayer11-Sep-05 7:42 
GeneralRe: C++ question Pin
El Corazon11-Sep-05 7:55
El Corazon11-Sep-05 7:55 
GeneralRe: C++ question Pin
Trollslayer11-Sep-05 13:53
mentorTrollslayer11-Sep-05 13:53 
GeneralRe: C++ question Pin
Blake Miller12-Sep-05 4:38
Blake Miller12-Sep-05 4:38 
GeneralRe: C++ question Pin
Marc Clifton11-Sep-05 8:03
mvaMarc Clifton11-Sep-05 8:03 
GeneralRe: C++ question Pin
DavidNohejl11-Sep-05 8:09
DavidNohejl11-Sep-05 8:09 
GeneralRe: C++ question Pin
Marc Clifton11-Sep-05 8:12
mvaMarc Clifton11-Sep-05 8:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.