I'm trying to take a users input and break it up into four separate numbers, then take those numbers and arrange them from smallest to largest.So far I can't seem to get them working right.
Code:
# include <stdio.h>main ()
{
int inputVariables[4]; //where userinput goes after being broken up
int arrangedValues [4];// the user values arranged lowest to highest
int i;
int j;
}
I have been working on this program for days now and for some reason my program will not write to my third file. It will call all of the integers that I need it to call but it will not write them out to a file. How to use my loop correctly.
#include <iostream> #include <fstream> using namespace std;
But how would I do this using parallel_for_each (C++AMP) ? I need this for some algorithm that works with very long arrays and I think GPU would do this faster than CPU (even if I use all threads).
My program reads a string of characters. Prints all occurrences of letters and numbers, sorted in alphabetical and numerical order. Letters will be converted to uppercase.Other characters are filtered out, while number of white spaces are counted.
The problem is it crashes when i run the program. Here is my code
#include <iostream> const int SIZE = 100; using namespace std; int main() { char *pStr, str[SIZE] = "", newStr[SIZE] = "", ch; int count = 0, i = 0, j;
I'm writing a simple program to sort numbers through use of a pointer. I've always been bad with pointers, and I tried to use a typical temp value to hold the value, but i feel like I am over doing it.
#include <iostream> using namespace std; void SortTests(int *, int); int main() { int *ptr; int tests;
I'm trying to make a number sorting program with other features, but the numbers are all wrong.
#include <iostream> #include <iomanip> #include <fstream> using namespace std; void readData(int list[], int size); int main() { int size = 50; int scores[50] = {0};
For my project I have to sort 5 numbers and 5 names using a template bubble sort. I have one header for the numbers, and one for the names. This is what I have so far for my testing page:
#include "Floatheader.h" #include "Nameheader.h" #include <string> int main () myFloat obj1; myFloat obj2( 2.2, 5.1);
[Code] .....
I have to create a template to look like this: template<>....with a class inside the arrows. Then, I have to use bubble sort to sort the 5 names and number objects I have created. Sorting the names and numbers and also using templates?
We've only covered up to Functions and how to use reference variables inside the function parameter.
One of the hw problem that was assigned was to write a void function that takes three parameters( num1, num2, num3) by reference and sorts their values into ascending order, so that num1 has the lowest, num2 the middle value, and num3 the highest value. For example, if user enters: 14, -4, 8, then the output should look like this:
-4 8 14
I've completed the program with a bunch of if/ else if statements but I was wondering if there was a more efficient way to sort the numbers. Bear in mind, we've only covered materials up to functions so I can't use any other new techniques that we haven't cover yet. Here is my code:
// This program will take three int parameters by reference and sorts their value into ascending order //so that num1 has the lowest value, num2 has the middle value, and num3 has the highest value #include <iostream> using namespace std; // declare function with reference parameter that with sort numbers void sortNum(int &, int &, int &); int main () {
I am a beginner at C++, the output is pretty self explanatory. I'm trying to make a number sorting program with other features, but the numbers are all wrong.
Code: #include <iostream> #include <iomanip> #include <fstream> using namespace std;
What kind of code should i use for sorting numbers in both ascending and descending order? I don't know how to use bubble sorting either, is there another easy way to sort this out?
My program reads a string of characters. Prints all occurrences of letters and numbers, sorted in alphabetical and numerical order. Letters will be converted to uppercase.Other characters are filtered out, while number of white spaces are counted.
the problem is it crushes when i run the program
Here is my code
#include <iostream> const int SIZE = 100; using namespace std; int main() { char *pStr, str[SIZE] = "", newStr[SIZE] = "", ch; int count = 0, i = 0, j;
I have to write a program that sorts numbers from least to greatest. The way that it has to sort them is:
1) The program assigns the first number to be a minimum 2) If the next number is less than the minimum is now that number and they switch places. (We keep on looking if the number next to it is not smaller) 3) The program also gets the index of the minimum number 4) We keep on going until it is in order.
// Sort.cpp : Defines the entry point for the console application. //
#include "stdafx.h" #include <iostream> #include <vector> using namespace std; void Sort(vector<int>&input); int _tmain(int argc, _TCHAR* argv[]){ vector <int> input;
I tried to sort a large numbers of vector of random integers with std::sort(), but when the number increases over 10M, std::sort returns all zero in values. Does std::sort have a limitation of input numbers?
I have a code able to import a file containing words and numbers to a linked list, but I also need to sort this linked list alphabetically. I've done research on this involving bubble sorting, but no explanationcan achieve this objective.
Below is the code that can only put the file into linked list:
Code: #include<iostream> #include<conio.h> #include"U:C++WordClass2WordClass2WordClass.cpp" #include<fstream> #include<vector> #include<string> using namespace std;
This compiles fine but when I run the .exe for the first time an error message comes up saying program has stopped working. If I run the program again without recompiling it seems to work as expected.
User enters sentence "The Smiths have two daughters, three sons, two cats and one dog." (The numbers may change depending on what the user chooses to enter. He told us the range would be from zero to nine.) and we have to convert the written numbers within the sentence into actual decimal numbers and print out the new sentence. Ex. The Smiths have 2 daughters, 3 sons...etc.
I have written the following bit of code which reads the string and finds all the "written numbers" but I am not sure how to proceed from there. I am stuck on how to print out the new sentence with the converted numbers as my professor mentioned something about creating the new string using dynamic memory allocation.
Code: #include <stdio.h>#include <string.h> int main () { char A[100]; int length = 0; int i;
Find all the prime numbers between a given pair of numbers. Numbers should be read in from an input file called "numbers.txt" and find all the prime numbers between them. Store the prime numbers in an array, then sort the array from greatest to least. Display the array before and after the sort.
I'm stuck on how to put the prime numbers into an array.
The input file has the numbers 1 & 100.
Here's what I have so far.
#include <iostream> #include <fstream> using namespace std; int main() { ifstream fin; fin.open("numbers.txt");
I'm working on this program that I have to design a class Numbers that can be used to translate whole numbers to the English description of the number.
Now this is what I got so far:
#include <iostream> #include <string> using namespace std; class Numbers { private: int number; static string ones[]; static string tens[];
[Code] ....
The program seems to work. However its not giving me the right number description,
Example:
Please enter the amount you would like translated into words: 5 six dollars please enter another number: 10 eleven dollars please enter another number: 20 thirty dollars please enter another number: 30 forty dollars please enter another number: 100 two hundred dollars please enter another number: 150 two hundred sixty dollars please enter another number: 500 six hundred dollars please enter another number: 1000 two thousand dollars please enter another number:
The code below will generate combinations of numbers from 1 to 25 in an 15 numbers array. The only filter I've applied is that the sum of all the numbers in the vectors divided by 15 needs to be between 13 and 14. I would like to count how many consecutive numbers there are in one combination, so that later i can apply another filter.. for example: