hdu 2071 Max Num

http://acm.hdu.edu.cn/showproblem.php?pid=2071

其实我觉得这不算一道dp题,它就是简单的暴力就可以了,甚至还可以用冒泡,但是我觉得我还是有点明白dp的思想了,所以把它看成dp吧,一次次记录max;直到最后一个数搜索完了。其实可以不用数组,有点多此一举了。

其实真的很简单。。

代码:

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

int main()

{

    int t,n;

    double s[102],max;

    scanf("%d",&t);

    while(t--)

    {

              scanf("%d",&n);

              scanf("%lf",&s[0]);

              max=s[0];

              for(int i=1;i<n;++i)

              {

                      scanf("%lf",&s[i]);

                      if(max<s[i])

                      max=s[i];

              }

              printf("%.2lf\n",max);

    } 

    system("pause");

    return 0;

}

原文地址:https://www.cnblogs.com/yuelingzhi/p/2125542.html