Visual C++ :: Random Linked Strings

Feb 9, 2013

I want to make a funny and simple game in cmd with visual studio and here is my plan, here are the steps that I wanna accomplish:

The program asks the person for

1: 4 girl names
2: 4 boy names
3: What they do? (4 actions)
4: Where they do this? (4 locations)
5: Random linked things

And from here I want to randomly get 1 line of a random girl name + random boy name + random action + random place. and followed by the second, third, and fourth line of random chosen things.

Like this:
Girl 1 - Boy 3 - Action 2 - Location 4;
Girl 3 - Boy 4 - Action 4 - Location 1;
Girl 2 - Boy 1 - Action 3 - Location 3;
Girl 4 - Boy 2 - Action 1 - Location 2;

And it can get funny like: Amber and John are jumping from a bridge. a game where you can play with your friends and have fun.

Here is my code so far:

#include<iostream>
#include<string>
#include<ctime>
#include<cstdlib>
int main (void) {
using std::cin;
using std::cout;
using std::string;

[Code] ....

And from here I don't know what to do!!

View 3 Replies


ADVERTISEMENT

C++ :: Generate Random Strings From A To Z With A Length Of 3 For Each Generation

Sep 16, 2014

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <ctime>
using namespace std;
string randstr(int);
int main()

[Code]...

I want to generate random strings from A to Z with a specific length of 3 for each generation. For example:

BRC
YUG
YFH

How do I fufill this with the code presented and the function at the bottom?

View 2 Replies View Related

C :: Convert From Strings To Integers And Pass Into Linked List

Feb 11, 2013

I have a problem set where i have to read in numbers from a file as strings, convert from strings to integers, and pass the integers into a linked list, where each integer is a node. This is what I have so far:

Code:
# include <stdio.h>
# include <stdlib.h>
# define MAX_INT_SIZE 10000
typedef struct integer BigInt;
struct integer {

[Code] ......

View 10 Replies View Related

C++ :: Doubly Linked List That Will Store Strings - Delete Function

Sep 23, 2014

I am creating a doubly linked list that will store strings, for example:

struct node{
string data;
node* next;
node* prev;
};

node* head; //first element from left to right (global)
node* tail; // last element from left to right (global)

And here is the function:

void deleteNode(int n){
struct node* temp1 = head;
if (n == 1){
head = temp1->next;
free(temp1);

[Code] .....

View 3 Replies View Related

C++ :: Bubble Sorting Linked List That Creates 100 Random Integers?

Feb 1, 2015

I am relatively new to C++ and am trying to bubble sort my linked list that creates 100 random integers. Everything works, but I am unsure how to continue this to include a bubble sorting method.

#include "stdafx.h"
#include <iostream>
using namespace std;
class Node{
public:
int data; //set data

[Code] ....

View 1 Replies View Related

C++ ::  assignment Is Recursive Call And Placing Strings In Linked List Notes

Oct 24, 2013

You need to write a permute class that will take first and second strings to rearrange letters in first, followed by second. For example, if the first is “CAT” string and second is “MAN” string, then the program would print the strings TACMAN, ATCMAN, CTAMAN, TCAMAN, ACTMAN, and CATMAN. The first and second strings can be any length of string or a null.

The permute class uses a Note class as link list note to link all letters arrangement. The permute class has Note pointers, firstNote and lastNote, to point to the beginning and ending Notes of the link list as private data members. There are three other private data members (total, firstString and secondString) to store the total possible number of arrangements and strings pass into the class.

Write a driver to test the permute class to pass in any two strings of any sizes.

Other than mention in the following, you can add more classes, functions, and private data members to this program.

Note class

The Note class needs to have two private data members and a constructor. The two private data members are data and p pointer. The data’s data type is string and p pointer is Note. The Note class constructor has two parameters, one is string and the other is Note pointer.

Permute class

The Permute class has five private data members (*firstNote, *lastNote, total, firstString and secondString). The firstNote and lastNote pointers are point to Note. The total has integer data type. The firstString and secondString have string data type.

There should have at least three public member functions, Permute, permutation and print. The Permute function is the constructor which takes strings to initialize the private data members. The permutation function does the recursive call to arrange the strings and setup the link list. The print function will print out the private data member information.

Driver file

The driver file should declare a Permute eight elements pointer array. Instantiate eight Permute object with the following eight set of data and assign the object to the pointer array. Use a repetition to call the object’s print function to print out the private data member information. If the total of the permute private data member is less than 100 then print out the permutated letters four in a row, otherwise print out 9 in a row.

first = "", second="",
first = "", second ="CATMAN",
first = "C", second ="ATMAN",
first = "CA", second ="TMAN",
first = "CAT", second ="MAN",
first = "CATM", second ="AN",
first = "CATMA", second ="N",
first 1 = "CATMAN", second ="";

View 19 Replies View Related

Visual C++ :: Relationship Between Two Hex Strings?

Aug 19, 2013

I'm trying to make an application for ELM327 trouble code scanning device for my own educational purpose. Most of my app code is done. however, I am stuck at one point. And I need finding relationship between two hex strings.

I have logged some communication between ECU and a chinese code scanning device for carrying out car's fuel pressure test. However there is one message (that is sent from the user side) that keeps on changing each time which is dependent upon the last message received from the ECU which is also varying every time.

Code:
RECEIVED (07E8) SEND (07E0)
05 67 03 0C 17 6A 00 00 05 27 04 8F 45 37 00 00
05 67 03 0C DB 68 00 00 05 27 04 B0 70 6B 00 00
05 67 03 10 3B 87 00 00 05 27 04 3B BC 10 00 00

[code]....

as it can be seen 3 bytes are always changing with each test, both, in the message received from the ECU, and the one sent back to the ECU from the diagnostic scanner. Trying to figure out relationship between these two strings?

P.S: about 16 million combinations for 3 byte data are possible... there must be some link between them...

View 4 Replies View Related

Visual C++ :: How To Access Argv Strings

Dec 22, 2012

I have:

int _tmain(int argc, char* argv[])
{
printf("drive name: %s
", argv[1]);

It displays only the first character of the first argument on the command line.

Yet the following works as expected:

static char* myArg[2] = {"first arg","second arg"};
printf("drive name: %s
", myArgv[1]);

That displays the entire string "second arg".

So what's wrong with my reference to argv[1]?

View 4 Replies View Related

Visual C++ :: Compare Two Strings To See Difference In Int Form

Apr 2, 2013

I want to compare two string, and want to see differeince in int form. For example,

Code:
string first_string="0002AE1";
string second_string="0002AE2";

How can i calculate difference between two string? It is obvious difference between above two string is 1/-1, but difference would be 1.

View 2 Replies View Related

Visual C++ :: Saving Unicode Strings To Txt Files

Jan 20, 2014

In my project , we need to create an Array of Unicode Strings . The Array will contain 5000 Strings.

I need to write those strings to a text file which can be opened or edited with NotePad.

Normal _tfopen and fwrite are not able to create notepad compatible .txt file .. I mean the file I created is not readable with Notepad though file open mode is "w+t"

How can I save my unicode strings to a text file

View 6 Replies View Related

Visual C++ :: Create A Function Using Rot To Encrypt Strings

Sep 30, 2013

I need to create a function using rot to encrypt certain strings the function begins like this

#include "encrypt.h"
std::string encrypt (std::string text, int rot) {
for (int i
and ends like this
return NULL;
}

dont need to write the string encrypted and dont need to crate a decrypt function.

View 4 Replies View Related

Visual C++ :: How To Do Binary Search On A Vector Of Strings

Sep 25, 2012

I'm trying to do a binary search on a vector of strings and keep getting this error. This is the PhoneEntry header file with the class declaration:

Code:
using namespace std;
#include<string>
#include<iostream>
#include<fstream>
#include<vector>
#include"phoneNumber.h"

[Code] .....

View 5 Replies View Related

Visual C++ :: Output Of Random Numbers

Apr 6, 2015

I wrote an code for generating an aoutpu of random numbers, but it doesn't gives me back the numbers here is the code:

#include <iostream>
#include <time.h>
#include <cstdlib>
#include <stdio.h>
#include <iomanip>
#include <cmath>
using namespace std;
const int ANZ = 6;

[Code] .....

I cant find the mistake.

View 2 Replies View Related

Visual C++ :: Random Lists Repeating

May 27, 2014

So I wanted to make a program which randomizes a list letters or something without repeating the letters like I get here:

Code:
#include <iostream>
#include <string>
#include <stdio.h> /* printf, scanf, puts, NULL */
#include <stdlib.h> /* srand, rand */
#include <time.h> /* time */
int main () {
using std::cout;
using std::cin;
using std::string;

[Code] ....

View 3 Replies View Related

Visual C++ :: Finding Items (strings) In Multiple Lists

Mar 12, 2013

Im working on a script compiler and i need to handle different types of data. Actually different categories of items.

Let's say i have two categories: cat's and bird's. They are different and stored in different lists. And let's say there is a simple command: GIVE_FOOD_TO(animal_type, food_type) Animal type here can be either from birds category or cat's category.

And also let's say user gives command: GIVE_FOOD_TO(cat1, fish)
and also for example: GIVE_FOOD_TO(bird1, birdfood)

Variable names could be anything, but im storing each variable name in std::map so later i can figure out with what animal current command is used.

When im parsing the script then i must know if user supplied either cat or bird. If i just would have cat's or bird's category then i would have only 2 lists and not a big problem to loop through either cats list or birds list and find out in what list the "cat1" is or in what particular list the "bird1" is. It would be in one or another.

But i have a lot of categories and looping through all of these lists (or std::maps) is slow and doesn't seem like a good. Just to find out in what list it's stored. I can't rely on variable names, they could be anything.

Big picture atm:

1) I have one BIG box which stores all of the categories

2) When i need to find out to which category the variable (animal_type) point's to i must get it quickly, dunno, std::map in std::map or something?

What i need basically is: I have different lists (each one is just a category for either birds or cats in this example) And when i have variable name, i must find out quickly in what particular category this item is stored. So i can work with it.

View 4 Replies View Related

Visual C++ :: Procedure To Compare 2 Strings With Specific Criteria?

Jul 10, 2013

Procedure to Compare 2 Strings with the following criteria

coding of the following function -

I have absolutely no clue where to start -

Given the following sets of numbers -

1154 1179 2154 2554 2484 2144 4515 1144 1517 4815 1481

Given the Index number of 1154

I want to search the numbers for the Index number of 1154

The search will return a True if I can find 3 or 4 same digits between the Index number and the 8 numbers

The search also have the following criteria -

meaning that -

1154 when compared to 1154 == true
1154 when compared to 1179 == false
1154 when compared to 2154 == true
1154 when compared to 2554 == false
1154 when compared to 2484 == false
1154 when compared to 2144 == false
1154 when compared to 4515 == true
1154 when compared to 1144 == true
1154 when compared to 1517 == true
1154 when compared to 4815 == true
1154 when compared to 1481 == true

the index number can also be of type - 1234, 1123, 1112, 1111

View 14 Replies View Related

Visual C++ :: Program That Take Strings From File And Push It Into Stack

Sep 29, 2013

How to write a programme that take strings from file and push it into the stack with number of each sting string before it and later clean the stack?

View 6 Replies View Related

Visual C++ :: How To Make Random Array To Not Repeat

Feb 17, 2013

Here is my code for a simple game. paste it and try it.

#include <iostream>
#include <string>
#include <ctime>
#include <cstdlib>
using namespace std;
int main (void) {
stringg[4],

[code]...

What they do (enter 4 actions)?

";
for (int ai = 0; ai < 4; ai++)
getline(cin, a[ai]);
cout << "

Where is happening (enter 4 locations)?

";
for (int li = 0; li < 4; li++)
getline(cin, l[li]);
for (int c = 0; c < 4; c++)
cout << g[rand() % 4] << " and " << b[rand() % 4] << " are " << a[rand() % 4] << " from a " << l[rand() % 4] << endl;
return (0);
}

At the end in the 4 lines some of the names, actions and locations repeat. How do I make them to not repeat and use every name that you will enter? do I need random_shuffle? How can I integrate it in my code?

View 1 Replies View Related

Visual C++ :: Unique Random Numbers In Array?

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

Visual C++ :: Roman Numeral Converter To Decimal Using Array Of Strings

Jun 27, 2013

This program compiles, but has a bunch of logical errors. I know my problem is somewhere in the while loop that I have, but I can't figure out where. Here are some of the issues I am experiencing:

1. At the beginning of the program it asks you to enter a number, and when you do it does nothing while proceeding to the while loop where I have it asking the same question

Code:
"Please enter a number between 1 and 20 (Enter 0 to stop)
";
cin >> num;
cout << endl;

I want to be able to eliminate that first statement but if I only run this in the loop without the above statement the program will display nothing on the screen and proceeds to stop.

2. This code runs fine, except that if you make a mistake, it will prompt you to enter a valid number, however; it ignores your first response if the number you enter is valid and asks you to enter a valid number anyway. Once you enter it a second time, it will accept it and the program will continue on.

Code:
while(num != SENTINEL) {
cout << "Please enter a number between 1 and 20 (Enter 0 to stop) ";
cin >> num;
cout << endl;

Also if you type in 0 on your first response, it will prompt you that it is not a valid number and ask you to try again, instead of stopping the program like it is supposed to do. On your second response the program will accept your 0 and stop the program correctly.

//Write a program that displays the roman numeral equivalent of any decimal number between 1 and 20 that the user enters. The roman numerals should be stored in an array of strings and the decimal number that the user enters should be used to locate the array element holding the roman numeral equivalent. The program should have a loop that allows the user to continue entering numbers until an end sentinel of 0 is entered.

Input validation: Do not accept scores less than 0 or greater than 20

#include <iostream>
#include <string>
using namespace std;
int main() {
// Declare constants and variables
const int romanNum = 21; // Size of the elements in the array

[Code] ....

View 14 Replies View Related

Visual C++ :: Rename Files With Random Names In A Folder

May 30, 2014

I need a code for renaming multiple(bulk or all ) files in a folder.

I found one batch file script but it renaming with numbers only. But i want differntly.

[URL] .....

Example:

In a folder there are 100 images and all numbered with some digits or names.

assume that all images are belongs to "john" , so i want to rename all images with "john+ a random string".

here a random string means -> it has an array with 3000 english words, (you can predefine them by downloading from dictonary).

In the script the 3000 names are fixed, but the 1st name will be changed by my wish. that my be john, mary, sai, pavan etc...

Suggestion: you do not need to enter all 3000 words in array manually. some javscript codes are there to read input of each and evey line and them into an array.

View 2 Replies View Related

Visual C++ :: Error When Trying To Read A Random Word From A File

May 8, 2015

I am currently writing a password generator in Microsoft Visual Studios 2010 Professional. The section I am having a problem with is the practical password. It is suppose to randomly read 3 words from a text file and then display it in the text box. The program will compile and run but when I hit generate I get "True True True" and not three random words. Then this warning shows up:

Warning C4800: 'char *' : forcing value to bool 'true' or 'false' (performance warning)

//Code is from the form1.h file. I can post the rest of the code if need be but I just included my includes and the problematic section

Code:
#pragma once
#include <cstdlib>
#include <ctime>
#include <stdlib.h>
#include <cmath>
#include <iostream>
#include <iomanip>

[Code] ....

Screenshot of the warnings: [URL] .....

Picture of the output: [URL] ....

View 3 Replies View Related

Visual C++ :: Assignment Is Recursive Call And Placing Strings In Link List Notes?

Oct 30, 2013

You need to write a permute class that will take first and second strings to rearrange letters in first, followed by second. For example, if the first is “CAT” string and second is “MAN” string, then the program would print the strings TACMAN, ATCMAN, CTAMAN, TCAMAN, ACTMAN, and CATMAN. The first and second strings can be any length of string or a null.

The permute class uses a Note class as link list note to link all letters arrangement. The permute class has Note pointers, firstNote and lastNote, to point to the beginning and ending Notes of the link list as private data members. There are three other private data members (total, firstString and secondString) to store the total possible number of arrangements and strings pass into the class.

Write a driver to test the permute class to pass in any two strings of any sizes.

Other than mention in the following, you can add more classes, functions, and private data members to this program.

Note class:The Note class needs to have two private data members and a constructor. The two private data members are data and p pointer. The data’s data type is string and p pointer is Note. The Note class constructor has two parameters, one is string and the other is Note pointer.

Permute class:The Permute class has five private data members (*firstNote, *lastNote, total, firstString and secondString). The firstNote and lastNote pointers are point to Note. The total has integer data type. The firstString and secondString have string data type.

There should have at least three public member functions, Permute, permutation and print. The Permute function is the constructor which takes strings to initialize the private data members. The permutation function does the recursive call to arrange the strings and setup the link list. The print function will print out the private data member information.

Driver file:The driver file should declare a Permute eight elements pointer array. Instantiate eight Permute object with the following eight set of data and assign the object to the pointer array. Use a repetition to call the object’s print function to print out the private data member information. If the total of the permute private data member is less than 100 then print out the permutated letters four in a row, otherwise print out 9 in a row.

first = "", second="",

first = "", second ="CATMAN",

first = "C", second ="ATMAN",

first = "CA", second ="TMAN",

first = "CAT", second ="MAN",

first = "CATM", second ="AN",

first = "CATMA", second ="N",

first 1 = "CATMAN", second ="";

View 3 Replies View Related

Visual C++ :: Linked List Search Function

Feb 9, 2014

The program I have below. If you copy and paste it it should work. However, When I uncomment my search function I get lots of errors and I think it has to do with incorrect syntax of it being a template. Need to do this search function:

Linked.h header file

Code:
#ifndef LINKED_H
#define LINKED_H
#include<iostream>
template <class T>
class Linked {
private:
// Declare a structure for the list

[Code] .....

View 2 Replies View Related

Visual C++ :: New Linked List Error - Undeclared Identifier

May 30, 2013

I dynamically allocate a new list in the recMergeSort function which should run a constructor but when it get to the functions that use it, I get error C2065: 'otherHead' : undeclared identifier. I have tried setting it to NULL and it didn't work. I even copied the default constructor to a set function and I still get the errors.

Code:
template<class Type>
void unorderedLinkedList<Type>::recMergeSort(nodeType<Type>* &head) {
otherHead = new nodeType<Type>;
if (head !=NULL)
if (head->link != NULL)

[Code] ....

wonder if I'm sending the correct data type. Here is the heading of the functions that I'm using from the book.

Code:
void unorderedLinkedList<Type>::divideList(nodeType<Type>* first1,
nodeType<Type>* first2)

View 6 Replies View Related

C++ :: Make 10 Random Numbers Thus Making 10 Random Flips Of Coin?

Aug 31, 2013

I want to make 10 random numbers thus making 10 random flips of a coin. I am getting 10 tails or 10 heads!

Code: #include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main(int argc, const char * argv[])
{

[Code].....

View 4 Replies View Related







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