# String# Input/Output

c726 - K-I-S-S-I-N-G (一行版)

🔗 前往 ZeroJudge 原題

題目描述

題目要求讀取兩個字串,分別代表女孩和男孩的名字,然後按照指定格式輸出包含這兩個名字的句子。

解題思路

此題為簡單的字串輸入輸出題。程式只需要讀取兩個字串,並將它們插入到預先定義好的句子中,然後輸出結果即可。沒有複雜的演算法或資料結構需求。

複雜度分析

  • 時間複雜度: O(1)
  • 空間複雜度: O(1)

程式碼

#include <iostream>
#include <string>

using namespace std;

int main (){
	
	string a,b;
	while(cin >> a >> b){
		cout << a << " and " << b << " sitting in the tree" << endl;
	}

}

Discussion