C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 30th, 2012, 04:38 PM
antmang antmang is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 1 antmang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 29 sec
Reputation Power: 0
Memory & arrays - Homework help :/

First time here so go easy
Here's the instructions for my homework :
Write a program that inputs 10 integers from the user into an array, and removes the duplicate array elements. By removing, I meant that you should make it appear as if the elements hadn't been there. So not just setting duplicates to an "empty" value, but filling in the gap. That means moving all the later elements back one (kind of like when you hit backspace in the middle of a line in a text editor). Or alternatively, storing only the non-repeating elements. You may assume that all the integers are between 0 and 100, Write at least 1 function in addition to the main function, and pass an array into that function as a parameter.

Here is my code + I am a beginner programmer sorry for blatant errors. The cout<<"yellow" part is just to test to see if the first part of my function is working, which it isnt. Could someone help me get it working and maybe hint at ideas for replacing the duplicate values? Thanks.
Code:
#include <iostream> 
using namespace std; 
int repeat[10]; void process(int repeat[10]); 
void process(int repeat[]) {
 int i;
 int dup = repeat[1]; 	
{ for(i=0; i< 10; i++) 
	if(repeat[i] != dup) //checking if repeat[i] is = to dup and if not print repeat[i] than replace dup with repeat[i] 	
     {cout << repeat[i]; 	
dup = repeat[i];} 		
else  		cout << "yellow"; 	}} 
 int main (void) {
int count = 0;
 int input; cout << "Please enter 10 integers, hitting return after each one: \n";
 for (; count<10; count++)
 {cin >> input; }//input from user
 process(repeat);//call statement 
system ("pause"); }

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Memory & arrays - Homework help :/


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap