C/C++ :: Compare Two Arrays And Print Out A List Of All Songs Without Repeating

Mar 11, 2014

I have two arrays:

const char *mymp3list[15] = { "Song 1", "Song 2", "Song 3", "Song 4", "Song 5", "Song 6", "Song 7", "Song 8", "Song 9", "Song 10", "Song 11", "Song 12", "Song 13", "Song 14", "Song 15" };
const char *myFriendsmp3list[20] = { "Song 1", "Song 2", "Song 3", "Song 4", "Song 5", "Song 6", "Song 7", "Song 8", "Song 9", "Song 10", "Song 11", "Song 12", "Song 13", "Song 14", "Song 15", "Song 16", "Song 17", "Song 18", "Song 19", "Song 20"};

And I want to compare the two arrays and print out a list of all the "songs" without repeating any.

I've figured out how to print the just the duplicates using:

for (int count = 0; count < SIZE1; count++){
for (int i = 0; i < SIZE2; i++){
if (mysonglist[count] == friendsonglist[i])
cout << mysonglist[count] << "
";
}
}

But I'm stumped on how to print a full list containing no duplicates.

View 4 Replies


ADVERTISEMENT

C :: Compare 2 Strings And Print Out 1 If Characters Match And 0 If Not

Oct 29, 2014

This program is supposed to compare 2 strings and print out a 1 if the characters match and a 0 if they dont. It compiles but doesnt give me the correct output.

Code:
#include <stdio.h>
#include <string.h>
void func();
int main () {
func();
return 0;

[Code] ....

View 11 Replies View Related

C/C++ :: Shuffle Songs Into Random Order

Sep 26, 2014

What's wrong with my shuffle function? It shuffles some songs, yet completely gets rid of others.

Here's the code:

void shuffle() //Shuffles songs into a random order. {
Music temp, temp2; //Temporary music file holders, 'Music' is a struct with string title;, string artist;, and int size;.
unsigned int currentTime = (unsigned)time(0);
srand(currentTime);
for (int i = 0; i < NUM_SONGS; i++)

[Code] .....

I want it to output this:

1. Title: Runaway2, Artist: Bon Jovi2, 2 MB
2. Title: Runaway5, Artist: Bon Jovi5, 5 MB
3. Title: Runaway1, Artist: Bon Jovi1, 2 MB
4. Title: Runaway4, Artist: Bon Jovi4, 1 MB
5. Title: Runaway7, Artist: Bon Jovi7, 5 MB
6. Title: Runaway6, Artist: Bon Jovi6, 5 MB
7. Title: Runaway3, Artist: Bon Jovi3, 5 MB
8. Title: Runaway8, Artist: Bon Jovi8, 1 MB

Or something along those lines, but instead I get something like this:

1. Title: Runaway7, Artist: Bon Jovi7, 1 MB
2. Title: Runaway2, Artist: Bon Jovi2, 2 MB
3. Title: Empty, Artist: Empty, 1856312448 MB
4. Title: Runaway4, Artist: Bon Jovi4, 1 MB
5. Title: Runaway5, Artist: Bon Jovi5, 5 MB
6. Title: Empty, Artist: Empty, 0 MB
7. Title: Runaway7, Artist: Bon Jovi7, 1 MB
8. Title: Empty, Artist: Empty, 1856312448 MB

View 2 Replies View Related

C/C++ :: Traversing A List Comparing To Compare Values?

Apr 22, 2014

I have a method that traverses a list to compare a number from the list to user input from elsewhere in the program. I have tried a few different things and I am probably overlooking something simple but my problem is my if statement is executing the else statement every run no matter if the input matches. This function is to return the location in the list that the num matches. -1 if no match, 0, 1, 2, otherwise depending on the number of nodes.

int NumberList::find(int num)
{
int temp = 0, count = 0;
ListNode *nodePtr;

[Code]....

View 2 Replies View Related

C :: Pull System Information And Compare Results With Predefined List

Feb 9, 2014

How to pull system information and compare it's results with a predefined list.

I know the second part, how to pull system information. Like what CPU/GPU/Motherboard the system that the program is run on has.

View 11 Replies View Related

C++ :: List Of Objects - Read Information From Each Object To Compare To User Input Prompt

Apr 19, 2013

I have a list of objects that I need to read information from each object to compare to a user input prompt.

#include "Passenger.h"
#include "Reservation.h"
#include "Aircraft.h"
#include <iostream>
#include <fstream>
#include <string>
#include <list>
using namespace std;
//Function Prototypes
void flightRoster(list<Reservation>&);

[Code] ....

View 1 Replies View Related

C :: Print Two Arrays On Same Table After Sorting

Jul 11, 2013

Having trouble with homework involving (title). Here is the assignment:Write a program that allows the user to enter 10 numbers from the keyboard. Sort the numbers using any sort routine you wish. The output from your program should be 2 columns of numbers. The left column should be the numbers in the order they were originally entered and the right column should be the sorted list. The columns should be labeled. You will need 2 arrays to accomplish this.

Use separate functions for input, sorting, and printing.So, I have to use separate functions for each of these. I would think it would be easiest to do the input in Main() and then the sorting and printing in another function, but of course since you can't return arrays I am kind of stuck on how I return the new array after sorting. I thought about doing the sorting in Main(), but then I would need to still do the original arrays input in a function and would still run into the same problem.

Here is what I have so far:

Code:

//Cameron Taylor
#include <stdio.h>
#define MAXARRAY 10
int highLow(int[], int);
int print(int[], int[], int);
int main (){
int unsorted[MAXARRAY], i, j, temp;

[Code]...

I know it seems simplistic right now, but I am just trying to get it to work first and then go back and beautify it up a bit.

View 9 Replies View Related

C :: How To Print The Max Number Row In Relation To The Char Arrays Row

Mar 30, 2013

I have most of the code working properly, but I'm having trouble with a certain area. Currently I have multiple 2D arrays. One is a char array and the other is an int array. In the int array I have to find the max number in each column, which I've done. The problem is, I need to print the max number's row in relation to the char array's row.

For example,

Code: int array[2][3] = {60 50 30 0 100 1}

The max numbers are 60, 100, 30.

char array[2][length+1] = {nameOne nameTwo}

How it needs to print:

nameOne has max score of 60.
nameTwo has max score of 100.
nameOne has max score of 30.

I just can't understand how to compare the two arrays in the right way, so it'll know that nameOne is associated with the numbers in row 0 and nameTwo in row 1, etc.

View 1 Replies View Related

C :: Why The Numbers Keep Repeating

Jul 8, 2014

Well I've given myself a lil project and I can't seem to figure out why the numbers keep repeating. What is the cause of this repetition. the function that generate the numbers is below

Code:

void numGen(struct Ticket *pick){
int x;
int y;
int check = 0;

[Code].....

View 6 Replies View Related

C++ :: Show First Non-Repeating Character?

May 25, 2013

How to show First Non-Repeating character?
"r"

#include <iostream>
#include <string.h>
#define MAX 100

[Code]....

View 7 Replies View Related

C/C++ :: Make Circular List And Print It

Apr 28, 2015

I have this program. I am trying to do this Circular List but i think something going wrong. The first of all is the list.The second is if my code for delete and select function are correct and the third i would like my program getting a "n" number of names and then make the circural list then print it and then when i select a number delete every node until give us the only one left.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 10
#define NUM_PER_LINE 6
typedef struct node {
char name[SIZE];
struct node * next;

[Code] .....

View 1 Replies View Related

C :: Generating Random Numbers Without Repeating?

Sep 20, 2014

Inside my loop is this

srand(time(NULL))
a=rand()%10;

So it will generate numbers again and again as the loop goes on but it always repeat some numbers. My question is, how would you generate numbers without repeating? Somebody told me that i have to use auto increment, but i really have no idea about that.

View 8 Replies View Related

C++ :: Build Min Heap With No Repeating Values

Jul 10, 2013

10,11,20,1512,22,24,19,22

i want to write a c++ program to build min heap which gets above values from user. remember this program should not alloduplicate values to enter. it should discard duplicate values.

View 11 Replies View Related

C/C++ :: Non Repeating Binary Pairs Of N Values

May 19, 2014

I am working with cart algorithm and i have the following problem,i need to try all possible splits of n values in order to determine the best.

So lets say i have 3 values("low","medium",high) then the possible splits(pairs) would be:

(assuming low=0,medium=1,high=2)

0,1-2 low,medium-high
1,0-2 medium,low-high
2,1-0 high,medium-low

For 4 values(a,b,c,d) it would be:

ab,cd
ac,bd
ad,bc
abc,d
adb,c
adc,b
bcd,a

Problem is i dont know n so the solution must be recursive. The possible splits are 2^(n-1)-1. I am really stuck and most of the code is complete for cart and i really don't want to restrict it to binary values.

View 1 Replies View Related

C/C++ :: Remove Repeating Numbers In Array?

Nov 14, 2014

Question was:

QuoteWrite a program that reads in ten numbers and displays distinct numbers. If a number appears multiple times, it is displayed only once.For example: if user enters 1,1,2,3,4,4,5,1,0,9. You should output: 1,2,3,4,5,0,9. Order doesn't matter.

Steps:

a. Create an int[] to hold all the integers of user input and another int[] to store the distinct numbers.

b. Make a nested for-loops which the outer loop goes though the first array and inner loop to check if the value is already inside. Store the value to the second array if new number,otherwise do nothing.

c. Make a for loop to print out the elements of the second array

View 6 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

C++ :: Can't Get Specifically Ordered List To Print Properly

Dec 21, 2014

I'm writing a program where the user inputs a number of rows, and that many rows of @ symbols are printed, where the first row has the same number of columns as rows, and each next row decrements the number of columns by 1. It prints out a totally wrong output and whatever I try it won't print the right thing- currently when I input 4 it prints out 5 @ symbols on the first row, and then 3 on all the other rows.

Code:

#include <iostream>
using namespace std;
int main ( ) {
int rows;
cout << "How many rows? ";
cin >> rows;

[Code] .....

View 2 Replies View Related

C++ :: Print Linked List But As A Vector Of Char

Aug 26, 2013

I was assigned to print a linked list but as a vector of char (I cannot use the normal string type) , this is what I have:

char* List::asString(){
Node* ite = new Node();
ite= first;//ite is like an iterator of the list
for(int i=0; i<sizeOfList; ++i){//sizeOfList is the total of node of the list

[Code] ....

But when I print that, I get a bunch of weird symbols...

View 7 Replies View Related

C/C++ :: Most Repeating Element In Command Line Arguments

Jul 21, 2014

How do i find and output which one is most frequent from a given set of arguments on command line in c ?

View 4 Replies View Related

C/C++ :: Repeating Errors On Overloading Non Member Class Program

Oct 21, 2014

I am having a issues with an assignment in my class and don't really understand why. I am getting undeclared identifier errors even though I have declared and I am also getting an error. Here is the code:

#include "stdafx.h"
#include <iostream>
#include <cassert>

[Code].....

Last time I came to you all with an error it was a simple brain fart on my part but I don't think this one is like that. I would love to tell you what the program is supposed to do but I still do not really know, which might be part of the problem. I guess it outputs different sized rectangles...

View 7 Replies View Related

C/C++ :: Print Name And Ages Forward Then Reverse Using Double Linked List

Apr 28, 2015

I have to write a c program that will allow the user to enter names with ages. The name will be no longer than 40 characters. The name and age should be stored in a node of a doubly linked list. I cant use global data. I need to use 3 subroutines. the first one needs to enter the data and pass the head and tail pointers to the subroutine. the next subroutine needs to print the names and ages to the screen and file output.txt from first to last. the last subroutine needs to print out names and ages to the screen and file output.txt from the last to first.

Im getting several errors when i try to run this program. The first subroutine to get the data from the user and build the double linked list. but i seem to be having issues.

#include <stdio.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int entry(char [][41], int []); // subroutine used for data entry //
void printit(char [][41], int [], int); // subroutine used for data printing //
void reverseprintit(char [][41], int [], int); // subroutine used for reverse data printing //

[Code] .....

View 11 Replies View Related

C++ :: Read List Of Numbers From A File And Then Print Out In Reverse Order

Apr 6, 2013

1. Construct a class diagram that can be used to represent food items. A type of food can be classified as basic or prepared. Basic food items can be further classified as meat, fruit, veg or Grain. The services provide by the class should be the ability to enter data for new food, to change data for food and to display existing data about food.

using this class definition write a main program to include a simple menu that offers the following choices:

1. Add food
2. Modify Food
3. Delete Food
4. Exit this menu

2. Read a list of numbers from a file and then print them out in reverse order. State whether the list is palindromic or not.

View 2 Replies View Related

Visual C++ :: Program To Print List Using Iterator And Operator Overloading

Nov 19, 2014

I'm trying to use the given Iterators to overload my = operator to print my list to screen. I keep getting Link2019 error though and have narrowed the problem down to my print operator. I'm wondering if it has anything to do with the fact that my operator is in private part of class? I'm new to this concept.

Code:
#include "List.h"
// methods for Node all
//ME
Node::Node( const string &s, Node * p, Node * z) : word( s ), next( p ), prev(z)//constructor {
word = s; // init. word data with a copy of s
next = p; // next pointer points to p

[Code] .....

View 1 Replies View Related

Visual C++ :: Read Some Text And Output Without Displaying Repeating Words

Sep 8, 2014

I have been given an assignment to make a code to read some text nd display all the words nd the number of times they appear in another file or as output without displaying the repeating words. I made the code but its not giving any output.

#include<iostream>
#include<conio.h>
#include<fstream>
#include<string>
using namespace std;
void read(string);
string x,z,w;

[Code] ....

View 3 Replies View Related

C++ :: Date Class - List Major Holidays And Print Calendar For Given Year

Mar 20, 2013

I'm trying to implement a Date class to create a simple application for " Major U.S. holidays calendar System ", that provides a list of major holidays for a given year AND prints the calendar for the given year either online or write to a file. I need to finish up the class date.h, which is

#ifndef DATE_H
#define DATE_H
#include <string>
#include <iostream>
using namespace std;
string Month[]={"" , "January", "Febraury", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"};

[Code] .....

View 1 Replies View Related

C++ :: Convert List Of Binary Numbers From A File Into Decimal And Print To Screen

Sep 23, 2014

I am trying to make a program that will convert a list of binary numbers from a file into decimal and print the decimal to the screen. I have no problem doing the conversion, the problem comes up when our teacher wants the input file in a format as such:

3
10110101
11111111
10101010

The first number is supposed to tell the program how many different 8bit strings it is going to have to convert, and then the following lines are those binary numbers.

I am not very experienced with file inputs, and I know how to open files and read lines in.. The problem is, how to say "ok the first line says 3, so now I have to convert the next 3 lines" . I am assuming it is just a simple loop that I am missing....

View 4 Replies View Related







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