[ create a new paste ] login | about

Link: http://codepad.org/4y63syrc    [ raw code | output | fork ]

C++, pasted on Dec 1:
#include <iostream>
using namespace std;

int main () {
    int l[26] = {0};
    string palabra = "casas"; // no use espacios o va bugar XDD. solo letras minusculas. Si quieres mas hay que mejorarlo
    int i=0;
    int asc2 = 0;
        
    while ( i < palabra.size() ){
        asc2 = int ( palabra[i] );
        l[asc2 - 97]++; 
        i++;
    }
    
    for(int i = 0;i < 26; i++ ){
        if( l[i] != 0 ){
            cout << "Letra '" << char(i+97) << "'encontrada " << l[i] << " veces." << endl; 
        }
    }
    
    cout << palabra << endl;
    for ( i = 0; i < palabra.size(); i++ ){
        cout << l[ int (palabra[i])-97 ];    
    }
    cin.ignore();
    return 0;
}


Output:
1
2
3
4
cc1plus: warnings being treated as errors
In function 'int main()':
Line 10: warning: comparison between signed and unsigned integer expressions
Line 23: warning: comparison between signed and unsigned integer expressions


Create a new paste based on this one


Comments: