c++好像不能用gets()。。。
pintia 上用gets会出现编译错误。。
getline:(包含头文件string)
#include <iostream>
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main()
{
string s;
getline(cin,s); //可输入带空格字符串
int n=s.size(); //长度
cout<<s<<endl; //输出字符串
cout<<n<<endl;
return 0;
}
cin.get():
貌似这个时间最短。。。
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
char a[1005];
cin.get(a,1005);
int n=strlen(a);
printf("%s %d\n",a,n);
return 0;
}
cin.getline():
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
char a[1005];
cin.getline(a,1005);
int n=strlen(a);
printf("%s %d\n",a,n);
return 0;
}