没有思路 可以给点思路吗 写了一个但是不对 大家帮忙看看 感谢了 头秃
1条回答 默认 最新
- bostonAlen 2022-04-05 18:16关注
#include<iostream> using namespace std; void split(char *str) { int num_word=0; int temp=0,maxlen=0,maxwhere=0; for(int i=0;str[i]!='\0';i++) { if(str[i+1]=='\0'&&str[i]>='a'&&str[i]<='z') str[i+1]=' '; if(str[i]==' ') { num_word++; if(temp>maxlen) { maxlen=temp; maxwhere=i-temp; temp=0; } else temp=0; } else { temp++; } } cout << num_word << " " << maxlen << " "; while(str[maxwhere]!=' ') cout << str[maxwhere++]; } int main() { char str[500]; cin.getline(str,500); split(str); return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 SQL Server下载
- ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
- ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
- ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
- ¥15 python爬取bilibili校园招聘网站
- ¥30 求解达问题(有红包)
- ¥15 请解包一个pak文件
- ¥15 不同系统编译兼容问题
- ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
- ¥30 数字电源对DSP芯片的具体要求