class ll
{
public static void main(String args[])
{
String ss="hi he she";
byte a[]=ss.getBytes();
int n=a.length;
int c;
for(int i=0;i<n;i++)
{
if(a[i]=blank)
c++;
System.out.println("单词个数为:"+c);
}
}
}
有错误,实现不了
应该怎么做呢
现在没分了.不然给你100分
...全文
15318打赏收藏
怎么样统计数组中单词的个数
class ll { public static void main(String args[]) { String ss="hi he she"; byte a[]=ss.getBytes(); int n=a.length; int c; for(int i=0;i<n;i++) { if(a[i]=blank) c++; System.out.println("单词个数为:"+c); } } } 有错误,实现不了 应该怎么做呢 现在没分了.不然给你100分
String ss = "hi he she ";
byte blank = 'h';
byte a[] = ss.getBytes();
int n = a.length;
int c=0;
for (int i = 0; i < n; i++) {
if (a[i] == blank){
c++;
}
System.out.println("单词个数为: " + c);