C++ :: Multiple Sort Options?
Jan 9, 2013
I have the following private part of a class defined as follows:
private:
struct stats {
double ISIsum;
int authorCount;
bool operator<(const stats &a) const { return ISIsum > a.ISIsum;}
} *stats_;
bool compareSortByISI(const stats &lhs, const stats &rhs);
};
This enables me to sort this struct by calling:
std::sort(stats_, stats_ + authors_->getMaximumAuthors());
My question is, what if I want to have the option to sort by authorCount or ISIsum at run time. Is there any way to do this?
I can't see how I can override operator< twice and decide which one to call at use time.
View 2 Replies
ADVERTISEMENT
Apr 9, 2013
I am quite new to C programming. Now facing lots of problem with the code below. I attempt to convert he alphabet sorting into function prototype model but still facing warning during compilation.
Besides, I wish to open multiple file at the same time as well using array looping method, but got no idea to modify it...
[URL] ....
Code:
#include <stdio.h>
#include <string.h>
#define SIZE 255
#define LEN 31
// Function prototype
void alphabetisation (int final, char *webaddress[]);
[Code] .....
View 14 Replies
View Related
Mar 17, 2014
I have called a C function inside C++ code. The .so which gets created is a 32 bit while I am looking for 64 bit . What all options should be mentioned in the Make file to eventually compile and get shared object of ELF64 CLASS ?
Excerpts from Makefile
-----------------------------
CC = gcc
CXX = g++
CPPFLAGS = -I. -I$(S) -DHAVE_CONFIG_H
CFLAGS = -O2 -pipe
CXXFLAGS = -g -O2
LDFLAGS =
LIBS = -lsocket -lnsl
[Code] .....
View 1 Replies
View Related
Aug 5, 2013
I have been reading up, and it seems that all I need to do to finish up the installation of a library is to add in the search path for the library upon compile time.
Of course, I also read that directly copying the lib files can work too, but that may result in the over-writing of necessary files...
I read a more thorough document on mingw's linking processes and discovered that I could create a folder, install the library in that folder, and add the folder as a search path for mingw (so, basically, all i have to do is install all my libraries under that folder).
View 10 Replies
View Related
Mar 4, 2014
I am having problems with setting up a menu as a function. The point of the menu is to display a list of 4 options and the user is supposed to choose one option and then the program will run. I am having trouble understanding how to display the menu once I run it because it is not working.
#include <iostream>
using namespace std;
int menu(int ans); // function declaration for menu
void draw_triangle(int size, char ch); //function declaration for triangle
void draw_downtri( int size, char ch); // function declaration for upside-down triangle
void draw_diamond(int size, char ch); //function declaration for diamond
[Code] ....
View 1 Replies
View Related
Feb 3, 2014
Is there a way to access the router settings via c++? My friend wanted me to write something that would turn off wifi broadcasting on his router when pressing the button in the program. The only way I can think about is to connect to the router via .net framework and then use reverse engineering (on the router settings site) to find a way how to simulate change of option via POST or GET method.
View 5 Replies
View Related
Oct 8, 2014
I'm giving the replace option to my string:
void replace(string oldstring, string newstring) {
int stroldstringpos=b.find(oldstring);
b.replace(stroldstringpos,newstring.length(),newstring);
}
i have 1 error in these function that i'm confused. imagine the newstring size is more big than the oldstring, how can change the string, but only change the oldstring and add what left?
see these:
String test="hi hello world";
test.replace("hi","hello");
the result must be:
hello hello world
how can i change the replace function for it?
View 3 Replies
View Related
Feb 5, 2014
Using WPF and .NET 4.0 what would be the best way to utilize one panel but modify it for various options? For instance when having a basic or advanced view how would I go about changign the area to add buttons or other items most efficiently?
View 4 Replies
View Related
Oct 21, 2013
I am new to coding and have a question with my if else statement. This is a VERY simple program that I have made something like in Javascript before, but when I do it in C++ it does not work correctly. It displays both the options. Here is my code.
// Practice.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
// Asking for a number {
int x;
[Code] ....
View 14 Replies
View Related
Oct 17, 2014
I want to run the following code from the command line:
Code:
#include <iostream>
using namespace std;
#ifdef ABC
const int num = 105;
[Code] ....
But I can not activate the ABC macro from the command line.
I'm trying to use the -d ABC option following the .exe file name, but I could not run the ABC macro.
How can I activate the ABC macro when I run the .exe file from the Windows 7 command line?
View 13 Replies
View Related
Mar 23, 2014
I decided to create a simple program to display a menu with options, while that is easy enough I had some difficulty when selecting an option that has options inside which also has an option again. While I had many issues in the past I'm finally finished with it and it works fine, but being new to programming and not knowing various other methods available.
Code:
//:::::::::::::::::::::Simple Menu Program::::::::::::::::
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#include <iostream>
#include <string>
//function prototypes
[Code] .....
View 1 Replies
View Related
Oct 16, 2013
I need a program that has a login system and then a menu that has 3 options: Add, delete and exit. If I choose Add it wil ask for certain data of 5 students.
Then after registering the 5 students, another menu with the options: Search, Delete and exit. In search it will ask for an ID and then prints all the data of a single student. Delete gives me the option to delete the data of any user I choose.
View 1 Replies
View Related
Jul 28, 2014
My project is to make a options menu for the user to select a shape and than draw out the shape. That whole process is already done and ready to go. What i am having trouble on is totaling the number of selected shapes. For example, at the end of the program i need to prompt a message saying ("You have selected "shape" this many times "number").
View 1 Replies
View Related
Apr 12, 2014
I am using PDF Creator printer to print my files. I have set it as default printer. It displays two dialogs .. "Printer Setup Dialog" and "Dialog asking filename and other details to save to file".
I want to avoid these two dialogs. But EndDoc calls the other dialog by default. How to do this ?
View 13 Replies
View Related
Aug 19, 2013
Example radix sort function to sort an array of 64 bit unsigned integers. To allow for variable bin sizes, the array is scanned one time to create a matrix of 8 histograms of 256 counts each, corresponding to the number of instances of each possible 8 bit value in the 8 bytes of each integer, and the histograms are then converted into indices by summing the histograms counts. Then a radix sort is performed using the matrix of indices, post incrementing each index as it is used.
Code:
typedef unsigned long long UI64;
typedef unsigned long long *PUI64;
PUI64 RadixSort(PUI64 pData, PUI64 pTemp, size_t count) {
size_t mIndex[8][256] = {0};
/* index matrix */
PUI64 pDst, pSrc, pTmp;
size_t i,j,m,n;
UI64 u;
[Code]....
View 9 Replies
View Related
Mar 22, 2013
how to sort a 1D array using function sort().but if i have a 2D array how do i sort only 1 row of it (or column)?
View 2 Replies
View Related
Feb 19, 2014
You will write a program that uses a multidimensional array having 3 rows and 8 columns and sorts each of the rows using both a bubble sort and a selection sort.
You must declare the array inside of main. You will have a for loop containing the calls to bubbleSort and selectionSort. You need to pass into function bubbleSort and selectionSort the following: 1) each column of the multidimensional array, 2) the size of the column, and 3) a particular row number of the multidimensional array to be used for printing out the "pass" shown on the following pages.
I keep getting an error that the identifier for bubbleSort and selectionSort is not found. (Error C3861) Also, I feel like I'm missing something in int main() to get it to sort properly.
# include <iostream>
using namespace std;
int main()
{
[Code].....
View 14 Replies
View Related
Jul 31, 2014
I want to develop an application which can host multiple views of explorer (window), where as each window is totally separate from others. So that I can have multiple desktop views through my single explorer. Any built in feature in .NET ?
View 11 Replies
View Related
Aug 17, 2014
how to make subroutines and return multiple arrays.Before that, i wrote my program on matlab. could my program to be structured as following?
<header>
initial value of program;
subroutine1() {
calculating the first work;
return 2 or 3 arrays;
[code].....
View 14 Replies
View Related
Mar 21, 2014
I've been working on a function that works like a pipeline of a shell but receives a directory, go over it an search for every file to send it to a filter, something like this in bash "cat dir/* | cmd_1 | cmd_2 | ... | cmd_N", The only problem i have with the code is the redirection of the pipe descriptors.
Code:
int main(int argc, char* argv[]){
char** cmd;
int Number_cmd;
cmd = &(argv[2]); /*list of cmds*/
Number_cmd = argc-2; /*number of cmds*/
}
[code]....
The code is seems to work fine except when i run it with more than one command in example ("./filter DIR wc rev") in this case it returns
wc: standard input: Bad file descriptor
wc: -: Bad file descriptor
0 0 0
View 2 Replies
View Related
Jul 15, 2013
I'm using multiple C++ files in one project for the first time. Both have need to include a protected (#ifndef) header file. However, when I do that, I get a multiple definition error.
From what I found from research, adding the word inline before the function fixes the error. Is this the right way to do this, and why does it work? Should I make a habbit of just declaring any function that might be used in two .cpp files as inline?
View 5 Replies
View Related
Mar 1, 2012
Say I have 5 vectors of unsigned char each of size 5. I want to take the max of each index and store it in a new vector. What is the most optimal way to accomplish this?
My slow code:
Code:
vector<unsigned char> vec1;
vector<unsigned char> vec2;
vector<unsigned char> vec3;
vector<unsigned char> vec4;
[Code]....
View 3 Replies
View Related
Apr 10, 2013
why we use radix sort.
View 2 Replies
View Related
Feb 20, 2012
how can i use my function now in the main ... after i put the numbers for example i want them to be sorted in ascending or descending order
PHP Code:
# include <iostream>
using namespace std;
int main () {
int array [10];
cout << " enter numbers : ";
for ( int i=0; i<10; i++)
[code]....
View 4 Replies
View Related
Nov 25, 2014
I'm trying to sort strings as alphabetical but somewhere i have error.
Code:
#include <stdio.h>
#include <string.h>
int main(){
char s[100][20];
int num;
char temp[20];
int i,j;
[Code]....
View 1 Replies
View Related
Nov 7, 2014
I know how to sort an array but how I can sort an array regard to nth term.
Example: 2 --> nth digit 4 45 62 1 900 105 -->inputs
Output: 001 004 105 900 045 065
View 1 Replies
View Related