#16430: __求解


asddzxcc1856 (嚕踢)


#include <iostream>
#include <sstream>
using namespace std;

int main ()
{
int n=0;
string s;
while (getline(cin,s))
{

string t;
stringstream s1(s);
while (s1>>t)
{
int i,f=0;
for (i=0;i<t.length();i++)
{
if ((t.at(i)>='0' && t.at(i)<='9')|| (t.at(i)>='A' && t.at(i)<='Z')||(t.at(i)>='a' && t.at(i)<='z'))
f+=1;
if (f==1) n++;
}
}
cout << n << endl;
}
}

 

請問有什麼寫法可以讓n 等到讀取完全部的文章在輸出

 

 

跪求教學

#16433: Re:求解


asddzxcc1856 (嚕踢)


#include
#include
using namespace std;

int main ()
{
int n=0;
string s;
while (getline(cin,s))
{

string t;
stringstream s1(s);
while (s1>>t)
{
int i,f=0;
for (i=0;i<t.length();i++)
{
if ((t.at(i)>='0' && t.at(i)<='9')|| (t.at(i)>='A' && t.at(i)<='Z')||(t.at(i)>='a' && t.at(i)<='z'))
f+=1;
if (f==1) n++;
}
}
cout << n << endl;
}
}

 

請問有什麼寫法可以讓n 等到讀取完全部的文章在輸出

 

 

跪求教學

  ------>>>> 各位 大大 有沒有 比較好的寫法 可以給個建議嗎


#16438: Re:求解


ufve0704 (爬 我爬 我爬爬爬 有排行榜這種東西就是要爬 爬過我上面的那...)


#include
#include
using namespace std;

int main ()
{
int n=0;
string s;
while (getline(cin,s))
{

string t;
stringstream s1(s);
while (s1>>t)
{
int i,f=0;
for (i=0;i<t.length();i++)
{
if ((t.at(i)>='0' && t.at(i)<='9')|| (t.at(i)>='A' && t.at(i)<='Z')||(t.at(i)>='a' && t.at(i)<='z'))
f+=1;
if (f==1) n++;
}
}
cout << n << endl;
}
}

 

請問有什麼寫法可以讓n 等到讀取完全部的文章在輸出

 

 

跪求教學

  ------>>>> 各位 大大 有沒有 比較好的寫法 可以給個建議嗎


我有一個想法,值得一試,算他的空格數,但我還不熟char。