标题
增加 1 行删除 1 行
1字符数组21字符数组(二)
正文
增加 61 行删除 10 行
1234567891011121314151617181920212223242526272829303127 行未改动59606162# 最长单词2```cpp#include<bits/stdc++.h>using namespace std;int main() {int maxlen=0;bool flag=false;char word[500],res[500];while(cin>>word){int len=strlen(word);if(word[len-1]=='.') //判断是否是最后一个单词{len--;word[len]='\0';flag=true;}if(len>maxlen)//比较单词的长度{maxlen=len;strcpy(res,word);//复制}if(flag) break;}cout<<res;}```# 亲朋字符```cpp#include<bits/stdc++.h>using namespace std;27 行未改动elsecout<<"No substring";}```12345678910111213141516171819202122232425262728293031323334353637383927 行未改动676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113# 最长单词2```cpp#include<bits/stdc++.h>using namespace std;int main() {// string s,word;// getline(cin,s);// stringstream ss(s);// while(ss>>word)// {// cout<<word<<endl;// }int maxlen=0;bool flag=false;char word[500],res[500];//word每次输入的单词 res最长单词while(cin>>word){int len=strlen(word);//获取输入单词/字符数组的长度if(word[len-1]=='.') //如果单词最后面是‘.’,长度-1{len--;//长度-1word[len]='\0';//‘.’换成‘\0’,字符数组结束的标记flag=true;//标记输入结束}if(len>maxlen)//擂台比较//当前长度比之前长{maxlen=len;//替换当前最长长度strcpy(res,word);//最长单词给res 复制}if(flag) break;//结束输入}cout<<res;}```# 亲朋字符```cpp#include<bits/stdc++.h>using namespace std;27 行未改动elsecout<<"No substring";}```# 配对碱基链```cpp#include<bits/stdc++.h>using namespace std;char c[300];int main(){cin>>c;int len=strlen(c);for(int i=0;i<len;i++){if(c[i]=='A') cout<<"T";else if(c[i]=='T') cout<<"A";else if(c[i]=='G') cout<<"C";else cout<<"G";}}```# 连续出现的字符```cpp#include<bits/stdc++.h>using namespace std;char ch[1005];int main(){int k,ans=1;cin>>k>>ch;for(int i=0;i<strlen(ch)-1;i++){if(ch[i]==ch[i+1]) ans++;else{if(ans>=k){cout<<ch[i];return 0;}else ans=1;}}cout<<"No";}```