找出字符串中最大的数字

#include <stdio.h>
#include <iostream>
using namespace std;

int main()
{
    char str[80];
    //int arr[80], temp, pos = 0, n = 0, i, max = 0, flag;
	int temp;
	int pos = 0;
	bool flag ;
	int maxnumer = 0;
    printf("请输入字符串:
");
    scanf("%s", str);

    while (str[pos] != '')
    {
        temp = 0;
		flag = false;//设置是否有整数的标志
        while (str[pos] >= '0' && str[pos] <= '9')
        {
            temp = 10 * temp + str[pos] - '0';
            pos++;
            flag = 1;
        }
        if (flag)
        {
            if (temp >maxnumer)
            {
				maxnumer = temp;
            }
            pos--;//由于在存整数的时候多走了一步,要减1
        }
        pos++;
    }
	cout << maxnumer <<endl;
}
原文地址:https://www.cnblogs.com/liuweilinlin/p/3343702.html