f_evgeny wrote:Неохота влезать в ...
![Radio :radio%:](./images/smilies/radio.gif)
Сабина
A. Fig Lee wrote:Ето у Вас не С++. Ето С. С вкраплениями С++.
Если СТЛ не проходили, то ладно, иначе используйте
std::string, string::find string::replace
katyaever wrote:Вот что я здесь напридумывала... Я сделала копию етого array и пытаюсь сравнить их.
Here is how I understand:
1. I have to make an outer loop to display the characters of the array, if they are letters.
2. The inner loop then takes the first element of the array (array[i], i is initialized to 0) and compares it to the first element of the copy of that array (copyOfArray [index], index is initialized to 0). If they are the same index is inceremented by 1, index++. The inner loop then takes the 1st element of the array and compares it to the 2nd element of the copy of the array (if array[0] == copyOfArray[1]), and so on.
When I put in the code, following this logic, everything is displayed fine, except the counts are all screwed up!!!
WHERE DID I GO WRONG?![]()
![]()
P.S. А что такое массив?![]()
Code: Select all
// Объявление массива
char array_of_number_of_letter[255] =;
// Инициализация массива
for(int i=0;i != 256;i++){
array_of_number_of_letter[i] = 0;
}
// Считываем строку по однму символу
for (int i = 0; string [i] != 0; i++) {
// Для каждого считываемого символа
// увеличиваем на единицу член массива
// с индексом равным ASCII коду символа
// возможно, нужно будет сделать cast
// для string[i]
array_of_number_of_letter[string[i]]++;
}
// Теперь значение каждого элемента вашего массива
// с индексом, равным ASCII буквы, содержит
// количество этих букв в строке.
katyaever wrote:Я увиделаЕсли СТЛ не проходили, то ладно
И вспомнила песенку, ето мы не проходили, ето нам не задавали... парам-пам-пам
f_evgeny wrote:CTAC_P wrote:f_evgeny wrote:Пардон, если что не так понял.
Боюсь что Char не обязан быть всегда равным 0..255
Ну так просветите, а то я не понял, что Вы имеете в виду.