Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main() {
- char s[1000];
- char ans[1000];
- char curStr[1000];
- scanf("%s", s);
- int n = strlen(s);
- int i = 0; int maxcnt = -1;
- int isLastDigit = 0;
- int curCnt = 0;
- for (i = 0; i < n; i++) {
- if (isLastDigit == 1) {
- if (s[i] >= '0' && s[i] <= '9') {
- curCnt++;
- curStr[curCnt - 1] = s[i];
- } else {
- if (maxcnt < curCnt) {
- int j = 0;
- maxcnt = curCnt;
- for (j = 0; j < maxcnt; j++)
- ans[j] = curStr[j];
- ans[maxcnt] = '\0';
- }
- curCnt = 0;
- isLastDigit = 0;
- }
- } else {
- if (s[i] >= '0' && s[i] <= '9') {
- isLastDigit = 1;
- curCnt = 1;
- curStr[curCnt - 1] = s[i];
- }
- }
- }
- if (isLastDigit == 1) {
- if (maxcnt < curCnt) {
- int j = 0;
- maxcnt = curCnt;
- for (j = 0; j < maxcnt; j++)
- ans[j] = curStr[j];
- ans[maxcnt] = '\0';
- }
- }
- if (maxcnt == -1) printf("-1");
- else printf("%s", ans);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement