Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 12-02-2004, 07:12 PM   #1
Member (4 bit)
 
Join Date: Dec 2004
Posts: 8
C++ arrays help

i need to write a program using a arrays to have a user input integers untill they enter a 0....then i have to have the program print every number they inputted and tell how many times that number has been inputted
for example,
i enter.......1, 4, 8, 2 , 1, 1, 9, 6, 4,
it should then say
1 was entered 3 times
4 was entered 2 times........and so on.

does anyone know how to do this?
tominator is offline   Reply With Quote
Old 12-02-2004, 09:53 PM   #2
Member (8 bit)
 
rcvalencia9's Avatar
 
Join Date: Oct 2004
Location: Manila, Philippines
Posts: 221
How do you separate inputs. Using the enter key or you just accept one digit integers.

I already forgot to program already C++ but its the same with C. Here's my code using C

include
int num[1..100],times[1..100],x,y,z,a,b;

main()
{
x=0;
do
{
read(&i,num[x]);
x++;
}
while (num[x] != 0);

for (z=0;z {
for (b=0;b<1000;b++){replace 1000 by the range of the data type Integer. I think its 4500+}
{
if (num[z] == b)
{
a++;
times[z]=a;
}
}
a=0;{set var a back to 0}
}

for (z=0;z printf("%i was entered %i times \n",&num[z],&times[z])

getch()
}
rcvalencia9 is offline   Reply With Quote
Old 12-02-2004, 11:20 PM   #3
Member (4 bit)
 
Join Date: Dec 2004
Posts: 8
i need it in C++

i need this program to be only in C++
tominator is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:12 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2