【数据结构入门训练DAY-22】Little Ke‘s problem

文章目录

  • 前言
  • 一、题目
  • 二、解题思路
  • 结语

前言

本次训练内容

  1. 训练解题思维
  2. 一周一次的洋文题训练

一、题目

Little Ke was admitted to the University and became a freshman. At the begin of their first year,  Little Ke was hard-working and selected as the monitor. In order to be close to his teachers, please help him to write a program to ask teachers' names, and then print a message to tell him/her that it's nice to meet him/her.

输入格式

a string with length L (0<=L<=2^10)

输出格式

a sentence that meet the condition.

样例输入

Sean

样例输出

What is your name? Hello Sean, nice to meet you.

二、解题思路

        首先先翻译这道题:“小柯被大学录取,成为大一新生。第一年伊始,小柯勤奋努力,被选为班长。为了接近他的老师,请帮助他写一个程序来询问老师的名字,然后打印一条消息告诉他/她很高兴见到他/她。”你会发现题目描述和解题一点关系都没有……(真是绷不住了)。然后我们观察后面的样例,哦!!!原来就是打出一句话,把那个名字加入即可哈哈哈。

#include 
#include 
using namespace std;
int main() {
    string s;
    getline(cin,s);
    printf("What is your name? Hello %s, nice to meet you.",s.c_str());
}

 记得使用getline,因为没说不使用空格。

总结

        在最后发现是因为没写getline问题的时候,我已经有些许破防了,已经第二次这样了,我得错过几次才能记住啊!!!!好吧实话说,一开始我都没想到会有空格,想着就是一个简单的字符串输入输出,吃一堑长一智.2,希望它能就停留在.2了,希望各位看到了也留个心眼。

你可能感兴趣的:(数据结构入门训练,数据结构,算法)