程序設計與算法(三)期末考試之012:編程填空:Printer

總時間限制: 

1000ms

 

內存限制: 

65536kB

// 在此處補充你的代碼

描述

完成以下程序,使得輸入的整數x,以及若干正整數,將
大於x的正整數輸出;然後輸入若干字符串,將字符串長度大於x的字符串輸出

#include<iostream>
#include<algorithm>
#include<vector>
#include<bitset>

using namespace std;


class Printer{
int main(){

	int t;
	cin >> t;
	while(t--) {
		int n,x;
		cin>>x>>n;
		
		vector<int> intVec;
		for(int i = 0;i < n; ++i) {
			int y;
			cin >> y;
			intVec.push_back(y);
		}
		for_each(intVec.begin(), intVec.end(), Printer(x));
		cout<<endl;
		
		vector<string> strVec;
		for(int i = 0;i < n; ++i) {
			string str;
			cin >> str;
			strVec.push_back(str);
		}
		for_each(strVec.begin(), strVec.end(), Printer(x));
		cout<<endl;
	}
	return 0;
}

輸入

第一行是整數t,表示一共t組數據
每組數據有三行 
第一行是整數x和整數 n 
第二行是n個整數 
第三行是n個不帶空格的字符串

輸出

對每組數據
先按原序輸出第一行中大於x的正整數(數據保證會有輸出) 
再按原序輸出第二行中長度大於x的字符串 (數據保證會有輸出)

樣例輸入

2
5 6
1 3 59 30 2 40
this is hello please me ha
1 1
4
this

樣例輸出

59,30,40,
please,
4,
this,

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章