find.cpp
来源:互联网 发布:数据质量问题 编辑:程序博客网 时间:2024/06/07 03:55
//============================================================================
// Name : find.cpp
// Author : mtt
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <string.h>
#include <string>
#include <fstream>
#include <vector>
using namespace std;
string s[3];
int main ()
{
ifstream in("33");
int i=0;
vector<string> s1,s2;
while(getline(in,s[i]))
{
cout<<s[i]<<endl;
i++;
}
string line= s[0]+s[1]+s[2];
cout<<line<<endl;
string separators(" \t:,\v\r\n\f"),word;
int start=0,end=0,pos=0,count=0,wordlen=0;
int max=0,min=0;
while ((start=line.find_first_not_of(separators,end))!=string::npos)
{
count++;
end =line .find_first_of(separators,start);
if (end==string::npos)//最后一个单词
{
wordlen=line.size()-start;
}
else {
wordlen=end-start;
}
word.assign(line.begin()+start,line.begin()+start+wordlen);
cout<<word<<endl;
cout<<wordlen<<endl;
if (count==1)
{
max=min=wordlen;
s1.push_back(word);
s2.push_back(word);
}
else
{
if(wordlen>max)
{
max=wordlen;
s1.clear();
s1.push_back(word);
}
if(wordlen==max)
{
s1.push_back(word);
}
if(wordlen<min)
{
min=wordlen;
s2.clear();
s2.push_back(word);
}
if(wordlen==min)
{
s2.push_back(word);
}
}
}
vector<string>::iterator it;
for(it=s1.begin();it!=s1.end();it++)
{
cout<<*it<<endl;
}
for(it=s2.begin();it!=s2.end();it++)
{
cout<<*it<<endl;
}
return 0;
}
// Name : find.cpp
// Author : mtt
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <string.h>
#include <string>
#include <fstream>
#include <vector>
using namespace std;
string s[3];
int main ()
{
ifstream in("33");
int i=0;
vector<string> s1,s2;
while(getline(in,s[i]))
{
cout<<s[i]<<endl;
i++;
}
string line= s[0]+s[1]+s[2];
cout<<line<<endl;
string separators(" \t:,\v\r\n\f"),word;
int start=0,end=0,pos=0,count=0,wordlen=0;
int max=0,min=0;
while ((start=line.find_first_not_of(separators,end))!=string::npos)
{
count++;
end =line .find_first_of(separators,start);
if (end==string::npos)//最后一个单词
{
wordlen=line.size()-start;
}
else {
wordlen=end-start;
}
word.assign(line.begin()+start,line.begin()+start+wordlen);
cout<<word<<endl;
cout<<wordlen<<endl;
if (count==1)
{
max=min=wordlen;
s1.push_back(word);
s2.push_back(word);
}
else
{
if(wordlen>max)
{
max=wordlen;
s1.clear();
s1.push_back(word);
}
if(wordlen==max)
{
s1.push_back(word);
}
if(wordlen<min)
{
min=wordlen;
s2.clear();
s2.push_back(word);
}
if(wordlen==min)
{
s2.push_back(word);
}
}
}
vector<string>::iterator it;
for(it=s1.begin();it!=s1.end();it++)
{
cout<<*it<<endl;
}
for(it=s2.begin();it!=s2.end();it++)
{
cout<<*it<<endl;
}
return 0;
}
- find.cpp
- 找不到cpp文件 C1083:cannot find \xxx\xxx.cpp
- Leetcode 162. Find Peak Element (Medium) (cpp)
- Leetcode 389. Find the Difference (Easy) (cpp)
- Leetcode 277. Find the Celebrity (Medium) (cpp)
- Leetcode 153. Find Minimum in Rotated Sorted Array (Medium) (cpp)
- Leetcode 287. Find the Duplicate Number (Hard) (cpp)
- Leetcode 366. Find Leaves of Binary Tree (Medium) (cpp)
- Leetcode 295. Find Median from Data Stream (Hard) (cpp)
- Leetcode 438. Find All Anagrams in a String (Easy) (cpp)
- cpp
- CPP
- CPP
- cpp
- cpp
- CPP
- CPP
- 关于Can't find Class org.cocos2dx.cpp.AppActivity的解决
- 隐马尔可夫模型--3
- PostgreSQL简介
- 霍布斯:人对人像狼一样
- webservice的开发模式
- Hibernate 级联删除
- find.cpp
- 在android中添加背景图片
- 为DataGridView增加行号
- SuperMap iServer Java6R 启动iserver服务出错
- EIP寄存器——详解(for me)
- tomcat 集群学习笔记
- 卢梭:人无往不在枷锁之中
- perl应用:从NCBI提供的信息中获取需要的序列(上)use Arrays
- 我看懂的设计模式 Factory Method工厂方法