Topic Link
Subject to the effect
Substrings refers to a contiguous stretch of string. Given a string s, you find lexicographically largest string.
Topic ideas
This question is not difficult, the answer is definitely suffix, but if you do not have skills such as string functions may be some difficult to write, to consolidate learning about string manipulation
Code 1
Substr function with the string
#include<iostream>
#include<string>
using namespace std;
string s,ans;
int main(){
cin>>s;
int d=s.size();
for(int i=0;i<d;i++){
ans=max(ans,s.substr(i));
}
cout<<ans;
return 0;
}
Code 2
A strcmp function, but also directly s + i becomes a suffix string
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=1e3+5;
char s[maxn],ans[maxn];
int main(){
scanf("%s",s);
int d=strlen(s);
for(int i=0;i<d;i++){
if(strcmp(ans,s+i)<0){
strcpy(ans,s+i);
}
}
printf("%s\n",ans);
return 0;
}