一,看题

1,字符串确实是我的弱项。

2,

二,看题解

 #include<iostream>
#include<string>
using namespace std;
int main(){
string a[];
string s;
int x;
cin>>x;
cin.get();//这一步很关键。
for(int i=;i<x;i++)
{
getline(cin,a[i]);
cout<<a[i]<<endl<<endl;
}
while(cin>>s)
{
cout<<s<<endl<<endl;
} }

1,但是我对于cin.get()这步还是感觉很奇怪。

这块的用法确实挺奇怪的,显然这块我不会。

2,说实话getline()的用法我也不明确。

然后肯定得改进一下

 #include<iostream>
#include<string>
using namespace std;
int main(){
string a[];
string s;
int x;
cin>>x;
// cin.get();
for(int i=;i<x+1;i++)
{
getline(cin,a[i]);
cout<<a[i]<<endl<<endl;
}
while(cin>>s)
{
cout<<s<<endl<<endl;
} }

两个程序的答案大致可以,但是你的第二个过不了由于上面多了两行空格;

你还是再思考思考这题目吧。

Q1094的更多相关文章

随机推荐

  1. k8s之系统组件架构-02

    k8s系统架构图 网络组件:calico+kube-proxy(IPVS) 网络暴露:traefik+ingress,分别对HTTP与TCP的服务暴露 存储:glusterfs(heketi管理) 日 ...

  2. find命令常用参数

    目录 -name -type -size -empty -inum -links -perm -user -group -atime -ctime -mtime -amin -cmin -mmin - ...

  3. MongoDB学习笔记(六)

    初识 MongoDB 中的索引 索引就像图书的目录一样,可以让我们快速定位到需要的内容,关系型数据库中有索引,NoSQL 中当然也有,本文我们就先来简单介绍下 MongoDB 中的索引. 索引创建 默 ...

  4. Spring Boot 整合 Shiro ,两种方式全总结!

    在 Spring Boot 中做权限管理,一般来说,主流的方案是 Spring Security ,但是,仅仅从技术角度来说,也可以使用 Shiro. 今天松哥就来和大家聊聊 Spring Boot ...

  5. Java 8——Base64工具

    在java 8之前如果需要使用base64编解码,必须使用三方库,如:apache的commons-codec. 但是java 8将base64编解码的工具引入进来: public class Tes ...

  6. php 安装xdebug扩展和配置phpstorm断点

    参考链接:安装xdebug扩展和配置phpstorm断点

  7. 2019-11-29-dotnet-通过-WMI-获取指定进程的输入命令行

    原文:2019-11-29-dotnet-通过-WMI-获取指定进程的输入命令行 title author date CreateTime categories dotnet 通过 WMI 获取指定进 ...

  8. Redis配置过程中的问题

    记录一下配置过程中的坑~~ 当Redis在服务器上安装完成后,get.set没有问题了,接下来在程序中使用看看... 首先 在配置文件redis.conf中,默认的bind 接口是127.0.0.1, ...

  9. 【翻译】Dockerfile参考

    Dockerfile参考 来自docker官方网址:https://docs.docker.com/engine/reference/builder/ docker能够从Dockerfile中读取指令 ...

  10. 2-Rocketmq产品架构(参考阿里云)

    参考链接:https://help.aliyun.com/document_detail/112008.htm