C# :: Replacing Names With Unique Numbers
Oct 27, 2014
I have a dataset which is a coauthorship network (a .txt file).I want to replace all the names of the authors with a unique number(no matter what the number is but it's important these numbers should be unique).
I've opened the dataset in excel then copy the author's names to another excel file,then I want to replace the authors names with their row numbers. what should i do?
View 3 Replies
ADVERTISEMENT
Jan 13, 2014
Is there a way of using a rand-function in a way that it seeds the same random numbers every time the function is used? I'm looking fomr something like:
int * randfunction(hash maybe){
//Fancy code...
return // quasi random numbers, same each time function is used.
}
I'm testing an algorithm where I need a set of unique random numbers. So far I've only used hard coded numbers on small scale test runs. I'd like to do the up scaling, but haven't really figured out how to seed random numbers like I need to.
View 4 Replies
View Related
Feb 11, 2014
Here is what I'm trying to accomplish (it is a rather simple program): A classroom of students are to grade a certain number of other exams. The exams should be distributed equally and RANDOMLY, every student should receive the same number of exams, and no student should receive their own exam to grade. The only problem I have is to generate unique random exams for each student. Right now, I have it set to where each exam is distributed the same number of times, every student gets the same number of exams to grade, and no one gets there own. However, I don't have any parameters that prevent one student from getting the same exam multiple time.
Here is an example output:
Student 1 will grade: 4 3 2 5 <- CORRECT OUTPUT (no exam appears more than once)
Student 2 will grade: 5 5 5 1 <- exam 5 appears three times
Student 3 will grade: 4 2 2 2 <- exam 2 appears three times
Student 4 will grade: 3 3 1 1 <- exams 3 and 1 each appear twice
Student 5 will grade: 1 3 4 4 <- exam 4 appears twice
(each exam appears four times and every student is assigned four exams. no one gets their own)
Here is my code (area of problem is close to the bottom):
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void create_class (int);
int main (void) {
srand(time(NULL));
[Code] ....
I tried keeping the exams for each student in the array exam and then checking each one every time I generate a number, but that didn't work.
View 8 Replies
View Related
Apr 28, 2014
We had to generate random, unique numbers in the range [1,15]. But running the program for several times showed a bug: It wouldn't always generate a new number for every repeated number. I can't figure out the problem, especially since it works half the time and I can't figure out what's making it work some times and not others.
bool flag1 = true, flag2 = true, flag3 = true;
int i, j = 1;
int[] A = new int[11];
Random rnd = new Random();
A[0] = rnd.Next(1, 15);
Console.WriteLine("1. = " + A[0]);
[Code] .....
View 14 Replies
View Related
Feb 24, 2013
Below is my code for a program that is suppose to generate and display six unique random numbers (between 1 and 54). The issue seems to be in my check for duplicates. I know what I am doing wrong but can't seem to find a way to fix it. I think it is getting stuck in an endless loop because the way I have written it looks like it checks the first value against itself which will of course look like a duplicate everytime.
Code:
#include<iostream>
#include<ctime>
using namespace std;
//function prototype
[Code]....
View 1 Replies
View Related
Apr 15, 2013
ive done a code for taxi's that arrive and depart, but i was wondering how i can use names of taxis as registration instead of numbers?
View 1 Replies
View Related
May 7, 2013
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?
View 1 Replies
View Related
Jul 25, 2014
Can names and numbers be stored in one array ? Like a telephone directory?
View 1 Replies
View Related
Dec 6, 2012
I am trying to write a program that would convert numbers of base 10, decimal numbers, to binary or hexidecimal numbers, base 2 and base 16. I want the program to run a loop through the various numbers input and store each number converted to the new type in a separate variable with the same basic name but different last letters/digits to differentiate between them and add them to the total.
Basically, I'm saying that i have the user input a number and letters. Let's say 15, d, b. So they want to convert 15 of decimal type to binary.
The program would then take the variable used to hold that number, and the other to variables to decide what function to perform on the number.
Then I will already have a variable initialized for the 3 possible conversions (binaryKey[], decimalKey[], hexideciKey[])
Then I want it to convert it and store the number at different places in the array to form the final number. Although, there is no way to predict what number the user will input, so there is no way of knowing initially where the converted place-value will need to be placed in the array.
I was wondering if there was a way to have the program run a loop where as the progression continues, it appends a number to the end of a universal name for the variables and then adds them together in the correct order creating the sequence that means that number.
In simpler terms:
Input a number: 15
Input type of base: d
Input converted type: b
Program then continually divides the number by 2, storing the remainder in a new variable
Such as: for(int i=1, i < (str(number).len), i++){
when i = 1, you would get
int number1;
[Code] ....
and so on. Is there a way to do this???
View 5 Replies
View Related
Feb 10, 2013
i have a vector of stores. i would like to delete the specified choice(store) from the list. Here is what i have but my erase statement is wrong and wont compile.
void Store::deleteSpecifiedStoreFromList(string choice) {
for (int i = 0; i < this->stores.size(); i++) {
if(this->stores[i].getStoreNames() == choice) {
this->stores.erase( std::remove_if( this->stores.begin(), this->stores.end(), choice ), this->stores.end() );
}
}
}
View 4 Replies
View Related
Dec 11, 2011
I have a question about an issue I am having on my final project. Within my ItemEntry.cs form, I am trying to get the application to append the already existing .txt file, rather than prompt the user to replace it. I can't seem to get the StreamWriter and FileStream to allow the user to write to the file.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
[Code] .....
View 1 Replies
View Related
May 22, 2014
Alright I hav a program that readings from a txt file but is there a way to replace some of the words that get loaded into the vector so for example if the txt has a list of animals and i want to replace the word bird for book is their a way to do that
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
[Code]....
View 1 Replies
View Related
Apr 4, 2013
I heard that const shall be preferred over #define . So I start to change my program accordingly.
But then below error message occurs during compilation:
#include "common.h"
#include "definition.h"
#include "particle.h"
int main() {
Particle *p = new Particle();
[Code] .....
I guess the error occurs because, when the line 9 of particle.h (File 4) is compiled, value of const int dimension is not seen by the compiler.
View 6 Replies
View Related
Aug 13, 2014
i'm trying to replace letters in a word...here's the code so far
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main (){
string s;
[Code] ...
The problem is if i type "nm" i'm not getting "mn" as the output, it's "mm"
I'm not trying to swap letters between them
View 1 Replies
View Related
May 19, 2014
Take this string for an example, "asdf 9.000 1.232 9.00 23.1 545.3"..Is there a way to replace any of the doubles with another double? Example: Replace the first "9.000" with a "10.0". I am aware that string::replace will do the trick, but how do I make it work for arbitrary cases? By arbitrary I mean that I don't know the size of the string to be replaced, I just want to be able to replace any number with a given number.
View 1 Replies
View Related
Jul 29, 2014
I'm writing a function that accepts a char array containing the title of a book as parameter, the following then has to take place:
1.) Extra white spaces between words need to be removed [DONE]
2.) Text has to be converted to title case, i.e each new word has to start with a capital letter [DONE]
3.) Lastly I have I text file (minors.txt) containing a number of words that should not be capitalized by the function, like "a" and "an", however I don't know how to implement this.
Example of end product:
ENTER THE TITLE OF THE BOOK: a brief hisTOry OF everyTHING
Correct Output:
bool Book :: convertToTitleCase(char* inTitle) {
int length = strlen(inTitle);
bool thisWordCapped = false;
//Convert paramater to lower case and
//Remove multiple white spaces
for (int x = 0; x < length; x++)
[Code]...
I was thinking of maby reading the words in the text file into a string array, and then comparing the two arrays to ensure that when a word is present in a text file, the word is not capitalized, however I don't know if that is possible between a string array and a char array.
View 3 Replies
View Related
Mar 5, 2014
I'm making a hangman game. All i need to do is after the user guesses the letter correctly it replaces the stars with that letter. I have been trying for the past 2 hours and cant get it. So basically I have to do this. DisplayWord.replace(0, theWord(0)) but I don't know how to put it in.
This is my code:
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
[Code].....
View 2 Replies
View Related
Oct 6, 2014
I am working on a parking lot scenario project using multidimensional arrays. The parking lot has 8 rows and 10 parking spaces in each row. Altogether there are suppose to be 30 cars parking in the lot and arrive in numerical order. I am suppose to generate a random number to represent the row and another to represent the space in the row.
The problem I have is that a few of the elements are being replaced. The project requires the car to check if the space is taken, if so it is to find another one. Here is what I have...
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define ROW 8
#define COL 10
#define CARS 30
void parkTheCars(int result[ROW][COL]);
void displayArray (int result[ROW][COL]);
[Code] .....
View 1 Replies
View Related
May 15, 2014
I have a Win32 C++ application which works pretty well, but I don't like the GUI and I want to replace it with one designed graphically, a la Windows Forms. What is the best strategy to port my code? I tried creating a new Windows Forms C++ application and got pretty far with it, but was stymied when trying to call my unmanaged functions on a button press. If I can't use Forms to add a GUI without completely rewriting the program, what's my best bet?
View 14 Replies
View Related
Sep 23, 2013
Code:
#include<stdio.h>
#include<string.h>
#define MAX 25
int main(void)
{
int ch;
[Code]....
i think that cause this program to be error.because when i using the reference from internet, the program was executed for sure.This code what i mean
Code:
#include <stdio.h>
#include <string.h>
#define MAX 10
int main () {
int ch;
char str[] ="This is a simple string";
char str1[MAX];
char str2[MAX];
[Code]....
and rather than that i didnt have anymore idea to make that replacing string.
View 6 Replies
View Related
Jan 25, 2013
This function should replace all instances of a character in a given character array, while returning the amount of characters changed, but I keep getting a segmentation fault at the highlighted area.
I'm only supposed to use pointers so arrays are out of the question, and I don't think we are allowed to use the string.h library as well. How I could avoid something the segmentation fault or ways to fix it?
Code:
int replaceChars(char replace, char find, char *input) { int i, j;
//Finds length
for(i = 0; *(input + (i + 1)) != '