吃字符串的空格

#include<iostream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<set>
#include<vector>
#include<string.h>
using namespace std;
const int maxn=1e5+10;
typedef long long ll;
 
int main()
{
	int n;
	cin>>n;
  
	char s;
	cin>>s;
	getchar();    //gerchar()我也不知道什么时候加  ,不对的时候加一下
//	char s1[11500]; 
//	cin.get(s1,11500);  //char *是cin.get(string,string.length());
	string s1;
	getline(cin,s1);   // getline is  string 对象 (cin,s1)
//	
//	int len = strlen(s1);
//	
	
//	int c = n-len;
	int c = n - s1.length();
	if(c > 0){
		
		for(int i = 0 ; i < c ; i++){
		cout<<s; 
	}
	
	cout<<s1;
	
}
 else
 
 {  
    int c1=s1.length() - n;
	
	for(int i = c1; i < s1.length()  ; i++){
		
		cout<<s1[i];
	} 
}
	
	
}
posted @ 2020-03-26 22:07  小申同学  阅读(157)  评论(0编辑  收藏  举报