字符串乘方https://www.acwing.com/problem/content/779/
解题思路:该主串=循环次数*最小子串的长度。
相关代码:#include#include using namespace std; int main(){ string s,a,sum; while(cin>>s,s!="."){ for(int i=1;i<=s.length();i++){ a=s.substr(0,i); //取s的字串a if(s.length()%a.length()==0){ for(int j=0;j 补充:
1 while(cin>>s,s!=".") //一边输入s一边判断是否为.
2 string a=s.substr(0,i); //substr()函数表示的是从字符串s中截取从下标0开始长度为i的字符串a。
- 举例:
#include#include using namespace std; int main(){ string s="abcdef"; string a=s.substr(0,2); cout<
- 相关代码结果:



