zoukankan      html  css  js  c++  java
  • 输入输出-StringStream的使用

     整形变字符串

    stringstream ssa;  ssa<<abs(a);
    stra = ssa.str();

    今天用了一下不过超时了

    这里的输入需要记录一下  G - Andy's First Dictionary 

    https://vjudge.net/contest/359711#problem/G

    #include<bits/stdc++.h> 
    #define N 10
    #define endl '
    ' 
    #define _for(i,a,b) for(int i=a;i<b;i++)
    using namespace std;
    typedef long long ll;  
    set<string> Set;
    int main(){    
    	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);     
    	string s; 
    	while( getline( cin,s ) ){
    		int len = s.size();
    		_for(i,0,len){
    			if( isalpha(s[i]) ){
    				if( s[i]<'a' ) s[i]=s[i]-'A'+'a';
    			}  
    			else s[i] = ' ';
    		} 
    		stringstream ss(s);
    		string tem;
    		while( ss>>tem ){
    //			cout<<tem<<endl;
    			Set.insert(tem);
    		}
    	}
    	for( auto i : Set) cout<<i<<endl;
    	return 0;
    } 

    #include<bits/stdc++.h> #define N 10#define endl ' ' #define _for(i,a,b) for(int i=a;i<b;i++)usingnamespacestd; typedeflonglong ll; set<string> Set; int main(){ ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); string s; while( getline( cin,s ) ){ int len = s.size(); _for(i,0,len){ if( isalpha(s[i]) ){ if( s[i]<'a' ) s[i]=s[i]-'A'+'a'; } else s[i] = ' '; } stringstream ss(s); string tem; while( ss>>tem ){ // cout<<tem<<endl; Set.insert(tem); } } for( auto i : Set) cout<<i<<endl; return0; }

  • 相关阅读:
    堆排序算法
    二叉树的创建、遍历(递归和非递归实现)、交换左右子数、求高度(c++实现)
    hdoj1010 奇偶剪枝+DFS
    常见排序算法c++总结
    B
    C
    D
    E
    G
    F
  • 原文地址:https://www.cnblogs.com/SunChuangYu/p/12381323.html
Copyright © 2011-2022 走看看