有在线编程自测怎么都能过,但保存并调试怎么也过不了的吗?
输入描述:
输入一个字符串。
输出描述:
输出字符串中最长的数字字符串和它的长度。如果有相同长度的串,则要一块儿输出,但是长度还是一串的长度
#include<stdio.h>
#include <stdbool.h>
#include <string.h>
unsigned int Continumax(char** pOutputstr, char* intputstr) {
char out[1024]="";
bool record = false;
bool copy = true;
int j = 0;
int len = 0;
int k = 0;
for (int i = 0; i < strlen(intputstr); i++){
if (record) {
j = 0;
}
if ((intputstr[i] >= '0') && (intputstr[i] <= '9') && (i != strlen(intputstr) - 1)) {
out[j] = intputstr[i];
record = false;
copy = true;
j++;
} else {
record = true;
if ((intputstr[i] >= '0') && (intputstr[i] <= '9')) {
out[j] = intputstr[i];
}
if (copy) {
if (len < strlen(out)) {
len = strlen(out);
k = 0;
strcpy(*pOutputstr, out);
} else if ( (len == strlen(out)) && len != 0) {
strcat(*pOutputstr, out);
}
copy = false;
}
}
}
printf("%s,",*pOutputstr);
return len;
}
int main()
{
char input[1024];
char output[1024];
scanf("%s",&input);
char out[1024]="";
bool record = false;
bool copy = true;
int j = 0;
int len = 0;
int k = 0;
for (int i = 0; i < strlen(input); i++){
if (record) {
j = 0;
}
if ((input[i] >= '0') && (input[i] <= '9') && (i != strlen(input) - 1)) {
out[j] = input[i];
record = false;
copy = true;
j++;
} else {
record = true;
if ((input[i] >= '0') && input[i] <= '9')) {
out[j] = input[i];
}
if (copy) {
if (len < strlen(out)) {
len = strlen(out);
strcpy(output, "");
strcpy(output, out);
} else if ( (len == strlen(out)) && len != 0) {
strcat(output, out);
}
copy = false;
}
}
}
printf("%s,",output);
printf("%d",len);
}
#include <stdbool.h>
#include <string.h>
unsigned int Continumax(char** pOutputstr, char* intputstr) {
char out[1024]="";
bool record = false;
bool copy = true;
int j = 0;
int len = 0;
int k = 0;
for (int i = 0; i < strlen(intputstr); i++){
if (record) {
j = 0;
}
if ((intputstr[i] >= '0') && (intputstr[i] <= '9') && (i != strlen(intputstr) - 1)) {
out[j] = intputstr[i];
record = false;
copy = true;
j++;
} else {
record = true;
if ((intputstr[i] >= '0') && (intputstr[i] <= '9')) {
out[j] = intputstr[i];
}
if (copy) {
if (len < strlen(out)) {
len = strlen(out);
k = 0;
strcpy(*pOutputstr, out);
} else if ( (len == strlen(out)) && len != 0) {
strcat(*pOutputstr, out);
}
copy = false;
}
}
}
printf("%s,",*pOutputstr);
return len;
}
int main()
{
char input[1024];
char output[1024];
scanf("%s",&input);
char out[1024]="";
bool record = false;
bool copy = true;
int j = 0;
int len = 0;
int k = 0;
for (int i = 0; i < strlen(input); i++){
if (record) {
j = 0;
}
if ((input[i] >= '0') && (input[i] <= '9') && (i != strlen(input) - 1)) {
out[j] = input[i];
record = false;
copy = true;
j++;
} else {
record = true;
if ((input[i] >= '0') && input[i] <= '9')) {
out[j] = input[i];
}
if (copy) {
if (len < strlen(out)) {
len = strlen(out);
strcpy(output, "");
strcpy(output, out);
} else if ( (len == strlen(out)) && len != 0) {
strcat(output, out);
}
copy = false;
}
}
}
printf("%s,",output);
printf("%d",len);
}