|
|
|
#1 (permalink) | ||||||||||||
|
Intel Overclocker
![]() |
So i'm learning array single dimensional and i have this problem to do but i don't know how to start it.
PHP Code:
__________________
|
||||||||||||
|
|
|
|
|
#2 (permalink) | |||||||||||||
|
Overclocker
![]()
Join Date: Oct 2006
Location: Levittown,PA / Penn State
Posts: 1,925
Rep: 86
![]() Unique Rep: 76
Trader Rating: 0
|
Quote:
int counts[26]; const char s[] = {'A','B',ect......}; cin >> input; int size = input.size(); for(int count = 0; count<input.size(); count++){ for(int i = 0; i<26; i++) { if(input.substr(count, 1).toUpperCase() == s[i]){ counts[i]++; i=26; } } } for(int l = 0; l<26; l++) { cout<<s[l]<<": "<<counts[l]<<" times"<<endl; }
__________________
|
|||||||||||||
|
|
|
|
|
#3 (permalink) | ||||||||||||
|
Intel Overclocker
![]() |
Hmm, thanks for posting but i can't use the input.substr i haven't learn it yet or is that written a different way?
__________________
|
||||||||||||
|
|
|
|
|
#4 (permalink) | ||||||||||||
|
Overclocker
![]()
Join Date: Oct 2006
Location: Levittown,PA / Penn State
Posts: 1,925
Rep: 86
![]() Unique Rep: 76
Trader Rating: 0
|
what string methods do you know?
charAt() is another you can use.
__________________
|
||||||||||||
|
|
|
|
|
#5 (permalink) | ||||||||||||
|
Intel Overclocker
![]() |
The regular one lol. The most basic basic string. I mean i can use C-string, but thats about it.
__________________
|
||||||||||||
|
|
|
|
|
#6 (permalink) | ||||||||||||
|
Overclocker
![]()
Join Date: Oct 2006
Location: Levittown,PA / Penn State
Posts: 1,925
Rep: 86
![]() Unique Rep: 76
Trader Rating: 0
|
yeah, cstring is what i am using too. but cstring has built in methods like size(), substr(), charAt().
__________________
|
||||||||||||
|
|
|
|
|
#7 (permalink) | ||||||||||||
|
Intel Overclocker
![]() |
I still need help on this if anyone could help me
__________________
|
||||||||||||
|
|
|
|
|
#8 (permalink) | ||||||||||||
|
Overclocker
![]()
Join Date: Oct 2006
Location: Levittown,PA / Penn State
Posts: 1,925
Rep: 86
![]() Unique Rep: 76
Trader Rating: 0
|
dude I gave you an answer. you can use substr or charat, trust me. They are built into the cstring class. It is part of cstring. IDK how much you know about programming. Why don't you ask your teacher what method she wants you to use?
Also a "thanks for your help" would be nice here and there. instead of just completely disregarding what is most likely the answer to your problem.
__________________
|
||||||||||||
|
|
|
|
|
#9 (permalink) | ||||||||||||||
|
Intel Overclocker
![]() |
Quote:
Quote:
Second, i'm very new to this so telling me stuff like substr, charat, is like speaking Korean to me. I clearly don't know what it mean. And how would i put it so it would run? I did PHP Code:
PHP Code:
__________________
Last edited by Mikey122687 : 4 Weeks Ago at 08:18 PM |
||||||||||||||
|
|
|
|
|
#10 (permalink) | ||||||||||||
|
Intel Overclocker
![]() |
what im confused is this
PHP Code:
I can't ask for help because my professor isn't teaching us anything. All he ever say is "read the book" and the whole class is simply learning on our own. I have to pretty much learn C++ by myself. Whenever i ask him for help, he told me to go read the book. And i did, but it doesn't mean i get all the materials.
__________________
|
||||||||||||
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|