#include
#include
#include
#include
using namespace std;
int main() {
char s[1001];
scanf("%s", s);
int length = strlen(s);
int maxnum = 0;
if(length==1) {
int tmpval = s[0]-'0';
if(tmpval>=0 && tmpval<=9) {
printf("%d\n",tmpval);
} else {
printf("9\n");
}
return 0;
}
for(int i=0;i<length;i++) {
int k=0; char temp[1001]; int count=0;
for(int j=i;j<length;j++) {
int val = s[j]-'0';
if(val>=0 && val<=9) {
temp[k] = s[j];
k++;
} else {
count++;
if(count==2) {
int tmp = atoi(temp);
if(maxnum<tmp) maxnum=tmp;
break; }
else {
temp[k] = '9'; k++; }
}
temp[k] = '\0';
int tmp = atoi(temp);
if(maxnum<tmp) maxnum=tmp;
}
}
printf("%d\n", maxnum);
return 0;
}
which test case i’m missing, i’m unable to figure it out.
what’s wrong with the above code