


各位有谁知道解答思路么
用题目做给条件进行作答
在线等候解惑
感谢
#include <stdio.h>
int findNum(char *str[], int n, int num[])
{
int count = 0, i, j, t = 0, f = 0;
char ch;
for (i = 0; i < n; i++)
{
j = 0;
ch = str[i][0];
while (ch)
{
if (ch >= '0' && ch <= '9')
{
t = t * 10 + ch - '0';
f = 1;
}
if (ch < '0' || ch > '9' || str[i][j + 1] == '\0')
{
if (f)
{
num[count] = t;
count++;
t = 0;
}
f = 0;
}
j++;
ch = str[i][j];
}
}
return count;
}
void order(int *a, int start, int end)
{
int t;
for (int i = start; i < end - 1; i++)
{
for (int j = i + 1; j < end; j++)
{
if (a[i] < a[j])
{
t = a[i];
a[i] = a[j];
a[j] = t;
}
}
}
}
int main()
{
char *str[3] = {"12df 34*99jji1", "we8967ii*ke3", "45ju7**66"};
int i, count;
int num[20] = {1, 2, 3, 4, 5};
for (i = 0; i < 3; i++)
puts(str[i]);
printf("\n");
count = findNum(str, 3, num);
order(num, 0, count - 1);
for (i = 0; i < count; i++)
printf("%d ", num[i]);
return 0;
}
