【程序设计与算法(一)】最长最短单词

要点:
strtok()字符串分割函数。(在后续课程中有详解这个函数,现在就先拿来用了)

【程序设计与算法(一)】最长最短单词_第1张图片

【程序设计与算法(一)】最长最短单词_第2张图片

#include
using namespace std;
#include

//大数组定义在外面 
#define num 20000 
char a[num];
int main()
{ 
 cin.getline(a,sizeof(a)) ;
 //字符串分割函数strtok(字符串,分隔符可以有多个) 
 char *p=strtok(a," ,");
 int max=0;//初始化最长单词长度 
 int min=100;//初始化最短单词长度 
 char *t;//指向最长单词字符串 
 char *m;//指向最短单词字符串 
 while(p!=NULL){
//  cout<max){
   t=p;
   sum=len;
  }
  if(len

你可能感兴趣的:(程序算法与设计(一))