public class Test { public static void main(String[] args) { String s="my address is #168 shanghai Road,beijing,100028"; int countNum=0; int countStr=0; int countSpace=0; int countOther=0; for(int i=0;i<s.length();i++){ char c=s.charAt(i); if(('0'<=c)&&(c<='9')) countNum++; else if(c==' ') countSpace++; else if((('A'<=c)&&(c<='Z'))||(('a'<=c)&&(c<='z'))) countStr++; else countOther++; } System.out.println(countNum+","+countStr+","+countSpace+","+countOther); } }
public class Test { public static void main(String[] args) { String s="my address is #168 shanghai Road,beijing,100028"; int countNum=0; int countStr=0; int countSpace=0; int countOther=0; for(int i=0;i<s.length();i++){ char c=s.charAt(i); if(('0'<=c)&&(c<='9')) countNum++; else if(c==' ') countSpace++; else if((('A'<=c)&&(c<='Z'))||(('a'<=c)&&(c<='z'))) countStr++; else countOther++; } System.out.println(countNum+","+countStr+","+countSpace+","+countOther); } }
------------------------------------------------------------- Quietly through .....
楼主【bll19840729】截止到2008-07-10 09:44:48的历史汇总数据(不包括此帖):
发帖的总数量:0 发帖的总分数:0 每贴平均分数:0
回帖的总数量:0 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:0 结贴的总分数:0
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:---------------------结分的百分比:---------------------
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
{
public static void main(String[] args)
{
String s="my address is #168 shanghai Road,beijing,100028";
int countNum=0;
int countStr=0;
int countSpace=0;
int countOther=0;
for(int i=0;i<s.length();i++){
char c=s.charAt(i);
if(('0'<=c)&&(c<='9'))
countNum++;
else if(c==' ')
countSpace++;
else if((('A'<=c)&&(c<='Z'))||(('a'<=c)&&(c<='z')))
countStr++;
else
countOther++;
}
System.out.println(countNum+","+countStr+","+countSpace+","+countOther);
}
}
public class Test
{
public static void main(String[] args)
{
String s="my address is #168 shanghai Road,beijing,100028";
int countNum=0;
int countStr=0;
int countSpace=0;
int countOther=0;
for(int i=0;i<s.length();i++){
char c=s.charAt(i);
if(('0'<=c)&&(c<='9'))
countNum++;
else if(c==' ')
countSpace++;
else if((('A'<=c)&&(c<='Z'))||(('a'<=c)&&(c<='z')))
countStr++;
else
countOther++;
}
System.out.println(countNum+","+countStr+","+countSpace+","+countOther);
}
}
Quietly through .....