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;

}

相关文章:

  • 2021-08-27
  • 2022-02-01
  • 2022-01-20
  • 2021-09-08
  • 2021-07-05
  • 2022-03-05
  • 2021-09-24
  • 2021-09-01
猜你喜欢
  • 2021-11-27
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-21
  • 2022-01-12
相关资源
相似解决方案