二周 3-1

来源:互联网 发布:sql with as 多次使用 编辑:程序博客网 时间:2024/06/10 08:41
#include <iostream>  #include "string.h"  using namespace std;  void main ()  {char string[81] ;    int  num=0 , word=0 ;     gets ( string ) ;         for ( int i=0 ; (string[i]!='\0') ; i++ )   {    if ( string[i]==' ' ) word = 0 ;    else if (word==0)          {           word = 1 , num++ ;}  }  cout << " There are " << num << "words in the line " << endl;   }  运行结果:

原创粉丝点击