|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#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? |
|
|
|
|
|
#2 |
|
Member (8 bit)
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 getch() } |
|
|
|
|
|
#3 |
|
Member (4 bit)
Join Date: Dec 2004
Posts: 8
|
i need it in C++
i need this program to be only in C++
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|