C++ :: Selection Process Using Roulette Wheel Selection?

Feb 9, 2013

I'm trying to make a selection process using roulette wheel selection. To do this I created two matrix, one random probabilities and one increasing probabilities. The idea is to choose a number according to the random probabilities. Here is the code I've written.

#include <iostream>
#include <conio.h>
#include <cstdlib>
using namespace std;
int main (){
float select [5], prob [10], mat [5];
int c, r, z;
cout.precision (2);
cout << "Random Number:" << endl;

[Code]...

The result I got is as follows:

Random Number:

0.0013 0.56 0.19 0.81 0.59

Increasing Probabilities:

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Selected Column:
0
5
6
8
9

The evaluation doesnt seem to start from c=0 again. The selected column should be 0, 5, 1, 8, 5.

View 6 Replies


ADVERTISEMENT

C :: Selection Sorting A 2D Array

Feb 13, 2013

Selection sorting a 2D array . Let's say i have an array like

1 2 3 4 //4 elements
1 2 // 2 elements
1 2 3 4 5 //5 elements
1 2 3 //3 elements
1 //1 element

And I want to do a selection sort it in descending order which the row with 5 elements will come first then 4 then 3 and so on. So that it would look like this

1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

Code:
void selectionSortDescending(int list[MAX_ROW], int size){
int temp;
int walk;
int curr;
int large; // index of the largest element

for (walk = 0; walk < size - 1; walk++)

[Code] ....

View 7 Replies View Related

C# :: Invert ListBox Selection?

Apr 18, 2014

I have my ListBox working and I'm able to select the items I want to keep. I'm trying to now get the Invert of the current selection for the items to delete.

I tried using:

if (lstLinePatterns == null) return;
for (int i = 0; i < lstLinePatterns.Items.Count; i++)
lstLinePatterns.Items[i].Selected = !lstLinePatterns.Items[i].Selected;

But
.Selected
is giving me an object error.

Is there an easy way to just inverse current selection?

Current Code:

private void btnSelectNonRvt_Click(object sender, EventArgs e)
{
// Unselects any Items to Prevent Infinite Loop
lstLinePatterns.SelectedIndex = -1;

[Code]....

View 3 Replies View Related

C :: Selection Menu With Enter Key Support

Apr 27, 2013

I am working on a database project, which can store (initially) 10,000 marksheets with following capabilities

1) new entry
2) edit/modification of entry
3)delete entry
4) separate Departements ( BBA, BCS, M.Phil, Phd., etc.)
5) can store data on files ( initially, all data is stored in a single file)

Now, I want to create a menu, in which i can use arrow keys to navigate through the menu and use Enter key fo selection.

What should i use in it?? The project is only on C language.

View 4 Replies View Related

C :: Implementing Selection Sort Algorithm

Jun 14, 2014

So i'm trying to implement the selection sort algorithm and it seems that the code is fine but...

Code:
#include <cs50.h>
#include "helpers.h"
void
sort(int values[], int n) {
// TODO: implement an O(n^2) sort

[Code] ....

I keep getting these errors and i don't understand why:

/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status

View 3 Replies View Related

C :: How To Create Menu Selection With Arrow Key

Jun 22, 2014

I'm looking for an example of menu selection with arrow key i'dont know how to create one o think i should use CODE ASCI but what method I should follow

View 1 Replies View Related

C++ :: How To Check User Selection (yes / No) On Message Box

Feb 10, 2013

How can you tell what button(yes/no) on a message box is clicked? Below is what I have right now but I am getting errors.

if (MessageBox(NULL,"The Message", "The Title", MB_YESNO) == IDYES){
do something
}

View 7 Replies View Related

C# :: Selection Font Not Supported In A Label?

Aug 24, 2014

I'm trying to transfer the font parameters from a richtextbox to a label but the label doesn't support .SelectionFont.

System.Drawing.Font currentFont = richTextBox.SelectionFont;
System.Drawing.FontStyle newFontStyle;
newFontStyle = FontStyle.Regular;
expanderLabel.SelectionFont = new Font(
currentFont.FontFamily,
currentFont.Size,
newFontStyle
);

View 2 Replies View Related

C/C++ :: Random Item Selection From Array?

Sep 6, 2014

I need to select a random item from an array but I am going to have more than 1 such array so I created the random value selector as different function. Right now I am getting a correct value for random function but when I try to access the array value associated with that index I get 2 digits which does not make any sense.

#include <iostream>
#include <cmath>
#include <ctime>
using namespace std;
int randFunction(int size);
int main() {
int heapsize;

[code]....

View 3 Replies View Related

C++ :: Selection Sort 2D Char Array

Feb 18, 2014

How to sort the last name instead of first name. Everything works so far and sorting is done on the first character.

#include <iostream>
#include <cstring>
using namespace std;
void sort(int, char[10][40]);
int main() {
char twoD[10][40];
int input = 0;

[Code] .....

View 4 Replies View Related

C# :: Get Selection From ComboBox / Getting Binding Path Instead?

Nov 19, 2014

I have a comboBox that I created in XAML using using binding and I'm unable to get the selection. I've tried everything I could think of or find on, but no luck.

Here's the relevant XAML and C# code for the comboBox:

<ComboBox Name="projSelected" Selectionchanged="projSelected_Selectionchanged" HorizontalAlignment="Left" Margin="424,27,0,0" VerticalAlignment="Top" Width="199" DisplayMemberPath="proj"/>
projSelected.ItemsSource = DAL.projectList;

Then here is where I try to check the selected value:

private void projSelected_Selectionchanged(object sender, SelectionchangedEventArgs e) {
projectDataList.ItemsSource = null;
projectDataList.Items.Clear();

[Code] ....

And here is my output in the MessageBox that I'm using to test the code:

Quote

project=Website selected=employeeProjects.project

View 7 Replies View Related

C Sharp :: How To Disable Selection Of 1st Row In DataGridView

May 3, 2012

how to disable selection of 1'st row in dataGridView.

I made it select some other row, but even so when u try to move with arrows on keyboard it'll select 2'nd row(cause 1'st row was selected initially and you can see it's selected on RowHeader-1'st/Left Column)

This is my code for selecting row:

dataGridView1.ClearSelection();
dataGridView1.Rows[BoPrI].Selected = true;
dataGridView1.FirstDisplayedScrollingRowIndex = BoPrI;

BoPrI is int variable that has Index Value

View 6 Replies View Related

Visual C++ :: CListCtrl On Dialog - Row Selection?

Aug 22, 2014

I have a ListCtrl on my dailog. It has a report view. In my case I have selected first row with left click of mouse and entire row is displayed in blue color as selection (as per expected) and when I right click the second row of the listctrl it displays the menu which I have added to it and the selection remains with the first row.(as expected). I have already overridden the ListCtrl class.

I want that on the right click of second row the selection should remain with the first row but this second row also should be displayed with dotted line border.

View 1 Replies View Related

C :: Selection Sort Program Crashes Right After Value Entered

Mar 25, 2014

I'm trying to code a Singly-Linked List(Double Pointers) selection sort program and I can't tell what the problem is. My compiler says no errors but when I run the program, it crashes right after I enter the values.

Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

typedef struct node{
int elem;
struct node* link;

[Code] ....

The compiler that I'm using is Dev-C++.

View 2 Replies View Related

C :: Sorting Strings Using Selection Sort Method?

Dec 7, 2013

I am trying to write a program to sort the characters in a word alphabetically. For example, if you input 'what', the computer will sort it into 'ahtw'. But, it fails to work. I didn't know why.

Code:

#include <stdio.h>
#include <string.h>
main() {

[Code].....

View 8 Replies View Related

C++ :: Credit Card Validation - Type Selection

Nov 17, 2014

We have to ask the user to select either a Visa card type or Mastercard type. Then, we must ask the user to enter the 16 digit card number and determine if the card is valid or not using module 10. If the answer is zero then it is a valid Visa card and if the answer is zero the answer is a valid MasterCard. My problem is that the I have not separated the validation for MasterCard separate from visa.

Here is what I have so far:

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main() {

string type, num;

[Code] ...

View 5 Replies View Related

C++ :: Calculate Total No Of Comparison Using Selection Sort?

Sep 15, 2014

how to put comparision condition in order to caculate total number of comparision in selection sort

static void selectsort(int[] data, int n)
{
int i, j;
for (i = 0; i < n; i++)

[Code]....

View 1 Replies View Related

C++ :: Selection Of Interesting Point From Long List

Mar 29, 2013

I have some codes which are not efficient enough to get the answer faster.

Q: Tom is looking for a car with high miles per gallon and high horse power.For example:P1--Toyota with MPG=51,HP=134, the P2--Honda with MPG=40,HP=110, P3--Ford Fusion with MPG=41,HP=191,P4--Nissan with MPG=35,HP=195,P5--Volkswagen with MPG=30,HP=140

Since,p2 is worse than p1(in terms of MPG,HP) and p5 worse than p4(MPG,HP), thus they are cancelled. The leftover 3 cars are considered interesting cars.Tom wish to find all interesting cars from the list but there's too many of them. Thus write a program to find this list as fast as possible.(C++)

int SimpleAlgo2 (int &n, int &d, vector< vector<float> > &point) {
vector<bool> isBest(n+10, true);
for (int i=0; i<n; i++) {
for (int j=0; j<n; j++) {

// We will check if point[i] is strictly worse than point[j]
// no need to check if we already know that point[i] is not the best
if (isBest[i]) {

[Code] ....

View 3 Replies View Related

C++ :: Selection Sort On Array Of Class Objects?

Jan 24, 2013

I have written a selection sort algorithm to go sort an array of class objects by age in ascending order, the problem is that the output being given does not match what i think the code should do. when the program runs the 3 records are added to the array and when they are sorted should be outputed in ascending order, the problem is that with my code the last 2 are sorted properly but the first element does not seem to move, it remains the same as the original unsorted value.

My code for the selection sort function and the display method are below:

void selectionSort() {
int i, minIndex, minValue;
for (i = 0; i < (arrlength - 1); i++) {
minIndex = i ;

[Code].....

View 1 Replies View Related

C++ :: Selection Sort For Non Decreasing Order Input?

Feb 17, 2013

Question: What is the efficiency and big O of the selection sort algorithm when the input happens to already be in nondecreasing order?

Answer: Not sure... since the input is in nondecreasing order, such that example 0, 1, 1, 2, 3, 4, 4, 5 then there will be no swap, Just comparisons of emelemts. So it is big O of n

View 2 Replies View Related

C# :: How To Use List Box Based On Radio Button Selection

Jun 2, 2014

How to put together this assignment. Here is the assignment:

The ABC Shipping Company charges the Rates listed in the following table:

Weight of the package (in kilograms) Shipping rate per mile in California Shipping rate per mile other states

2 kg or less $2.0 $2.5

Over2 kg but not more than 6 kg $3.0 $3.5

Over 6 Kg but not more than 10 kg $3.5 $4.0

Over 10 Kg but not more than 30 Kg $4.0 $4.5

Over 30 kg $5.0 $5.5

Create an application that contains two radio buttons to select California or other states, a listbox for the user to select the package’s weight class, a textbox to enter the distance it is to be shipped, and a button to calculate and display the charges on a label control when it is clicked.

Input validation: Do not accept distances of less than 5 miles or more than 3000 miles

This is what I have so far. I don't know how to set up the listbox option for non california or how to set up a formula.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

[Code] ....

View 3 Replies View Related

C/C++ :: Menu Selection Does Not Continue To Desired Screen

Mar 8, 2014

Basically we have to create a system for loan amortization for vehicle company. The code is still in its development stage and I am having problems with one of the menu selections. all the other menu selections work fine except for menu selection 3. I'm quite stuck on it. When I run the program everything goes well except when I enter 3 at the main menu, it just exits the program instead of going to the screen for the menu selection.

#include<stdio.h>
#include<conio.h>
#include<string.h>
main() {
char un, /*username*/
name, /*customer name*/

[Code] ....

View 1 Replies View Related

C# :: Datagridview Combobox Selection Clear After Adding New Row

Dec 25, 2014

I have 2 datagridview in one windows form, When I click row from datagridview1, it shows in datagridview2 (Select *from....). Also I have combobox column in datagridview2. My question is, when I select items in combobox, and click to new row in datagridview 1, datagridview2 combobox's is getting empty. it is my code:

private void dataGridView1_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e) {
try {
int id = Convert.ToInt32
(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["id"].Value);//3

[Code] .....

View 8 Replies View Related

Visual C++ :: CFileDialog Multiple Selection Limit?

Apr 30, 2013

In my attempt to capture multiple files using CFileDialog I discovered that there is a limit on the number of characters in the file name buffer. [URL]

I have used this code to get the file names and it works fine up to the point where the buffer is full. NB: m_vcsPathnames and m_vcsFilenames are std::vector<CString> types.

Code:
// get a list of the files to process
wchar_t szFilters[]= _T("All Files (*.*)|*.*||");
// Create an Open dialog; the default file name extension "*.*"
CFileDialog fileDlg(TRUE, _T(""), _T("*.*"),
OFN_FILEMUSTEXIST| OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT, szFilters, this);
m_vcsPathnames.resize(0);

[code]....

Is there any possible work around for this limitation, other than completely writing my own CFileDialogExx class ?

View 6 Replies View Related

C++ :: Sorting With Selection / Insertion And Bubble Sort

May 4, 2014

This program using the selection, insertion, and bubble sorts. The program needs to be able to do the following:

1. Create an array of 1000 population records when the array object is instantiated. Call it unSorted.

2.Open the file called "Population.csv" (on the portal) and invoke a function that loads the population data into the array.

3.Create a second array of 1000 elements that will be used to sort the data using the different algorithms. Name is sortedArray.

4.Write a function that will copy unSorted into sortedArray and execute that function.

5.Using a function, display the unsorted array.

6.Invoke the insertionSort () function that will sort the sortedArray using the insertion sort algorithm. Sort the population data on the rank field in ascending order. Alternatively, you can sort in descending order on population.

7.Using the display function, display sortedArray.

8.Display the number of iterations it took to do the sort using this algorithm.

9.Repeat steps 4-8 for the selection and bubble sort algorithms.

Here is my code so far:

Code:
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
void loadArray (int unSorted[], int s);
void displayArray (const int num [], int size);

[Code] .....

Here is a few lines from the Population.csv file contents:

Code:
Alabama,Baldwin County,140415,389
Alabama,Blount County,51024,908
Alabama,Calhoun County,112249,477
Alabama,Colbert County,54984,858
Alabama,Cullman County,77483,653
Alabama,Dale County,49129,927
Alabama,Dallas County,46365,974
Alabama,DeKalb County,64452,753

I'm not sure how to load the data from the file into the array properly, I attempted this. I also don't know how to copy the unSorted into sortedArray.

View 14 Replies View Related

C :: Selection Sort Algorithm For Singly Linked Lists

Feb 24, 2013

I've written code for a selection sort algorithm to sort through a singly linked list, However, it only brings the smallest node to the front, but doesnt swap positions of any of the remaining nodes, even though they are not in order.

Input list: 3 6 17 15 13 15 6 12 9 1 2 7 10 19 3 6 0 6 12 16

Sorted list: 0 6 17 15 13 15 6 12 9 1 2 7 10 19 3 6 3 6 12 16

Code:

#include<stdio.h>
#include<stdlib.h>
struct node{
int val;
struct node *next;

[Code] ......

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved