日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

NYOJ--811--变态最大值

發布時間:2023/11/27 生活经验 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 NYOJ--811--变态最大值 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/*Name: NYOJ--811--變態最大值Author: shen_淵 Date: 17/04/17 15:49Description: 看到博客上這道題瀏覽量最高,原來的代碼就看不下去了 o(╯□╰)o 
*/#include<cstring>
#include<iostream> 
#include<algorithm>
using namespace std;
struct group{int first,second,third;int max_value;//三個數中的最大值 bool operator<(const group &a)const{return max_value>a.max_value;}
}num[4000]; 
int main()
{int n,i,j;while(cin>>n){memset(num,0,sizeof(num));i = n/3;for(j=0; j<i; ++j){cin>>num[j].first>>num[j].second>>num[j].third;if((j+1)%2){num[j].max_value = (num[j].max_value = num[j].first>num[j].second?num[i].first:num[j].second)>num[j].third?num[j].max_value:num[j].third;}else{num[j].max_value = (num[j].max_value = num[j].first>num[j].second?num[j].second:num[j].first)>num[j].third?num[j].third:num[j].max_value;}}sort(num,num+i);cout<<num[0].max_value<<endl;}return 0;
}
/*Name: NYOJ--811--變態最大值 Author: shen_淵 Date: 17/04/17 16:12Description: 整理了一下以前的代碼 
*/
#include<stdio.h>
#include<malloc.h>
int smax(int a,int b,int c){int max;max = (max = a>b?a:b)>c?max:c;return max;
}
int smin(int a,int b,int c){int max;max = (max = a<b?a:b)<c?max:c;return max;
}
int main()
{int N;int n;int *a,*b;int mark = 0;while(scanf("%d",&N) != EOF){fflush(stdin);//清空輸入緩沖區 n = N/3;a=(int *)malloc(sizeof(int)*N);b=(int *)malloc(sizeof(int)*n);int i=0,j=0;for(i=0;i<N;i++)scanf("%d",&a[i]);i=0;while(i<N){if(mark%2){b[j++]=smin(a[i],a[i+1],a[i+2]);mark++;}else{b[j++]=smax(a[i],a[i+1],a[i+2]);mark++;}i += 3;}int d=b[0];for(i=1;i<n;i++)if(d < b[i])d=b[i];printf("%d\n",d);mark = 0;}return 0;
}



轉載于:https://www.cnblogs.com/evidd/p/7251964.html

總結

以上是生活随笔為你收集整理的NYOJ--811--变态最大值的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。