题目1386:旋转数组的最小数字

来源:互联网 发布:查看mysql数据库大小 编辑:程序博客网 时间:2024/06/04 19:37
#include <iostream>#include <cstdio>using namespace std;int main(){  int n;   while(~scanf("%d",&n))  {    int qian,hou;    scanf("%d",&hou);         if(n==1)    {         printf("%d\n",hou);    }    else    {        n=n-1;        int first=hou;        while(n--)        {            qian=hou;            scanf("%d",&hou);               if(hou<qian)            {               first=hou;             }           }        printf("%d\n",first);           }              }     return 0;      } /**************************************************************    Problem: 1386    User: 萧然677    Language: C++    Result: Accepted    Time:670 ms    Memory:1520 kb****************************************************************/

0 0
原创粉丝点击