XiangRui_FuZi! 题解分享 · 2025/3/1
拓拓在打字 - 题解
```C++ #include<bits/stdc++.h> using namespace std; int main(){ string s=" "; getline(cin,s); for(int i=0;i<s.size();i++){ if(s[i]==' '&&s[i+1]==' ') continue; cout<<s[i]; } return 0; } ```
0 0 1 2
re_uzume 题解分享 · 2024/4/7
拓拓在打字 - 题解
``` #include <stdio.h> #include <iostream> #include <string> using namespace std; int main(){ string str; while(cin>>str){ cout<<str<<' '; } } ```
0 0 1 3
zbz 题解分享 · 2024/4/7
拓拓在打字 - 题解
只要不是连续空格就输出 ``` #include<bits/stdc++.h> using namespace std; typedef long long LL; int main() { string str; getline(cin,str); for(int i=0;i<str.length();i++) { if(!(str[i]==' '&&str[i+1]==' ')) cout<<str[i]; } return 0; } ```
查看全文
0 0 1 1
橘子汽水7dnrj 题解分享 · 2025/4/6
拓拓在打字 - 题解
include using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; string c; getline(cin,s); for(int i=0;i 0&&i<=s.length()-2) { if(s[i] ==' '&&s[i+1]==' ') { continue; } else c.push_back(s[i]); } } cout<<c<<"\n"; return 0; }
查看全文
0 0 0 2
诗酒趁年华baltm 题解分享 · 2025/3/25
拓拓在打字 - 题解
include include using namespace std; int main() { string str; while (cin >> str) { cout << str << ' '; } //直接输入字符串,然后打印每一个字符串,且后面跟一个空格 return 0; }
0 0 0 1
MChaha165 题解分享 · 2024/10/12
拓拓在打字 - 题解
include using namespace std; int main() { string n; string a[12]; int i=0; while(cin>>n) { a[i]=n; i+=2; } for(int i=0;i<12;i++) { if(i%2==0) { cout<<a[i]; } else cout<<" "; } ``` return 0; ``` } // 0 1 2 3 4 5 6 7 8 9 10 11
查看全文
0 0 0 2
kunshao 题解分享 · 2025/3/6
拓拓在打字 - 题解
``` /* 思路分析 1. 接收字符串 只有一行 第一种想法:循环接收数据为字符数组 因为cin遇到空格会停止 最后循环加上一个空格 但是好像没有字符串数组 char数组好像也不行 第二种想法:用字符串直接接收 再用循环在不是空格的字符处传给动态字符数组 再循环加上一个空格 这个方法也废了 因为这样只能在每个字符后加空格 不是单词之后 第三种想法: 我创建一个字符数组 用cin输入遇到空格就停止 就是一个单词 再把它立即输出 输出时加上一个空格 perfect 遗憾的是这个想法也报废了 因为动态数组不能这样输入 幸运的是直接用字符串输入就解决啦 学到第四种: 使用stringstream A(B)分割函数 A是分割后的字符串 它的里面是动态字符串流 分割后不会存在空格 可以添加和提取 原理跟cin 和 cout 相似 A << 输入 A >> 输出 #include <bits/stdc++.h> using namespace std; int main() { string str; while(cin >> str) { cout << str << ' '; } return 0; } #include <bits/stdc++.h> using namespace std; int main() { string str; getline(cin , str); stringstream str1(str); //分割str放在str1字符串流里面 string str2; while (str1 >> str2) { //str2逐一提取每个单词 cout << str2 << ' '; } return 0; } */ ```
查看全文
0 0 0 1
栀子花 题解分享 · 2024/7/8
拓拓在打字 - 题解
``` #include <iostream> #include<stdio.h> #include <vector> #include <string> using namespace std; int main() { string str; getline(cin, str); int n = str.size(); for (int i = 0; i < n; i++) { if (str[i] != ' ' || (str[i] == ' ' && str[i + 1] != ' ')) cout << str[i]; } return 0; } ```
查看全文
0 0 0 2
47audience 题解分享 · 2024/4/7
拓拓在打字 - 题解
include using namespace std; int main(){ int n=0; string s; getline(cin,s); n=s.size(); for(int i=0;i<n;i++){ if(s[i]==' '&&s[i+1]==' ') ; else cout <<s[i]; } return 0; }
0 0 0 2
栀子花 题解分享 · 2024/7/8
拓拓在打字 - 题解
``` #include <iostream> #include<stdio.h> #include <vector> #include <string> using namespace std; int main() { string str; while (cin >> str) cout << str << ' '; return 0; } ```
0 0 0 1