#include <stdio.h>#include<string.h>intN;intsize;voidMain () {scanf ("%d", &N); GetChar (); //read the remaining carriage return characters for(inti =0; i < N; i++) { intindex =0; Charstrin[10000] = {' /'}; Charstrout[10000] = {' /'}; intcount['Z'] = {' /'}; Gets (Strin); //reading a string from the keyboardSize = (int) strlen (Strin); for(intj =0; J < size; J + +) { if(Strin[j] >='A'&& Strin[j] <='Z') {Count[strin[j]]++;//count the number of letters } Else return; } for(inti ='A'; I <'Z'; i++)//output the number of each letter { if(Count[i]! =0)//if the input string contains this character { if(Count[i] = =1) {Strout[index++] =i; } Else { intLen =0; Charstr[5] = {'/0'}; //strout[index++] = count[i] + ' 0 ';//count the same number of characterslen = sprintf (str,"%d", Count[i]); strcat (&Strout[index], str); Index+=Len; Strout[index++] =i; }}} printf ("%s\n", Strout); }}
#include <stdio.h>#include<string.h>intN;intsize;voidMain () {scanf ("%d", &N); GetChar (); //read the remaining carriage return characters for(inti =0; i < N; i++) { Charstrin[10000] = {' /'}; Gets (Strin); //reading a string from the keyboardSize = (int) strlen (Strin); for(intj =0; J <size;) { intK =0; if(Strin[j] >='A'&& Strin[j] <='Z') { Chartemp =' /'; Temp=Strin[j]; J++; K=1; while(Strin[j] = = temp)//determine if the next letter is the same{J++; K++;//count the same number of letters } //number of outputs and letters if(k >1) printf ("%d", K); printf ("%c", temp); }} printf ("\ n"); }}
HDU1020 string manipulation