110,538
社区成员
发帖
与我相关
我的任务
分享
using System;
namespace Text
{
class YouMother
{
}
}
string s= "abcdefg";
for(int i=0;i<s.length;i++)
{
convert.WriteLine(s.char(i));
}
def count(string):
s = list(set(string))
print s
length = len(s)
for c in s:
b = string.count(c)
print "there is %d %c in the string" % (b,c)
if __name__ == "__main__":
string = raw_input("please enter a string:\n")
count(string)
#include <iostream>
using namespace std;
void Handle(const char* const szStr)
{
if ( NULL == szStr ) return ;
const int conAsc = 128;
int nCount[conAsc] = {0};
char* pCur = (char*)szStr;
char cCur = *szStr;
while ( cCur )
{
nCount[cCur]++;
cCur = *++pCur;
}
for (int i = 0; i < conAsc; i++)
{
cout<< (char)i << "'s count = " << nCount[i] <<"\n";
}
cout<<endl;
}
"abcdefgabc"
.GroupBy(c => c)
.Select(g => String.Format("{0}, {1}", g.Key, g.Count()))
.ToList<string>().ForEach(p => Console.WriteLine(p));