13 条题解

  • 2
    @ 2023-3-5 19:35:54
    #include <iostream>
    #include<iomanip>
    #include<stdio.h>
    #include <math.h>
    using namespace std;
    int main(){
    	int a,b,maxn=-100000,minn=100000;
    	cin>>a;
    	for(int i=1;i<=a;i++){
    		cin>>b;
    		maxn=max(maxn,b);
    		minn=min(minn,b);
    	}
    	printf("%d %d",minn,maxn);
    }
    
    
    • 1

      浅浅地刷下题

      比较细

      #include <bits/stdc++.h>
      using namespace std;
      int n,a,maxn,minn;
      int main()
      {
      	maxn=-100001;
      	minn=100001;
      	cin>>n;
      	for(int i=1;i<=n;i++)
      	{
      		cin>>a;
      		if(a<-100000 || a>100000)
      		{
      			cout<<endl<<a<<"超出了100000或-100000,不计算";
      			continue;	
      		}
      		maxn=max(maxn,a);
      		minn=min(minn,a);
      		
      		
      	}
      	cout<<endl<<endl<<minn<<" "<<maxn;
      	return 0;
      	
      }
      
      • 1
        #include<iostream>
        using namespace std;
        int n,ax,in;
        int main(){
        	int n,x,ax=-100001,in=100001;
        	cin>>n;
        	for(int i=1;i<=n;i++){
        		cin>>x;
        		ax=max(ax,x);
        		in=min(in,x); 
        	}
        	cout<<in<<" "<<ax;
        	return 0;
        }
        
        • 1
          @ 2023-3-5 18:53:29
          #include <bits/stdc++.h>
          using namespace std;
          int main(){
              int n,d=-100001,a,x=100001;
              cin>>n;
              for(int i=1;i<=n;i++){
              	cin>>a;
              	d=max(a,d);
              	x=min(a,x);
              }
              cout<<x<<" "<<d;
          	return 0;
          }
          
          
          • 1
            @ 2022-12-20 22:01:11

            *,这水题竟然提交了3次才过😕 。。。 AC代码:

            #include<iostream>
            using namespace std;
            long long n,x,maxn=-100000,minn=100000;
            int main(){
            	cin>>n;
            	for(int i=1;i<=n;i++){
            		cin>>x;
            		maxn=max(maxn,x);
            		minn=min(minn,x);
            	}
            	cout<<minn<<" "<<maxn;
            	return 0;
            }
            

            点个赞吧!

            • 1
              @ 2022-1-8 11:45:07
              #include <stdio.h>
              #include <iostream>
              using namespace std;
              int main()
              {
              	int n,x;
              	cin >> n;
              	int minn , maxx;
              	minn = 10000000;
              	maxx = -1000000;
              	for(int i=0; i < n; i++)
              	{
              		cin >> x;
              		if(x >maxx)
              		{
              			maxx = x;
              		}
              		if(x < minn)
              		{
              			minn = x;
              		}
              	}
              	cout << minn << ' ' << maxx << endl;
              }
              
              • 0
                @ 2023-8-19 21:13:49
                /*********************************
                备注:
                *********************************/
                #include <iostream>
                #include <cstdio>
                #include <iomanip>
                #include <cmath>
                #include <math.h>
                #include <algorithm>
                #include <cstring>
                #include <string>
                #include <stack>
                #include <queue>
                #include <algorithm>
                #define LL long long
                using namespace std;
                const int INF = 0x3f3f3f3f;
                const int N = 1e5 + 10;
                int n , m , maxx = -INF , minn = INF ;
                int main()
                {
                	cin >> n;
                	for(int i = 1; i <= n; i++)
                	{
                		cin >> m;
                		maxx = max(maxx , m);
                		minn = min(minn , m);
                	}
                	cout << minn << " " << maxx;
                	return 0;
                }
                
                
                • 0
                  @ 2022-8-26 15:24:19
                  #include <iostream>
                  #include <algorithm>
                  #include <cstdio>
                  #include <cstring>
                  #include <string>
                  #include <iomanip>
                  #include <cmath>
                  #include <queue>
                  #include <map>
                  #include <stack>
                  #include <vector>
                  using namespace std;
                  #define LL long long
                  #define ULL unsigned long long
                  #define ULLI unsigned long long int
                  const int N = 1e6+6;
                  const int INF = 0x3f3f3f3f;
                  int main(){
                      int n,maxx = -999999,minn = 999999,k;
                      cin >> n;
                      for (int i = 1;i<=n;i++){
                          cin >> k;
                          maxx = max(maxx,k);
                          minn = min(minn,k);
                      }
                      cout << minn << " " << maxx;
                      return 0;
                  }
                  
                  • -1
                    @ 2022-10-25 13:21:46
                    #include <iostream>
                    #include <stack>
                    #include <cmath>
                    #include <vector>
                    #include <string.h>
                    #include <queue>
                    #include <stdio.h>
                    #include <iomanip>
                    #include <cstdio>
                    #include <algorithm>
                    #define int long long
                    using namespace std;
                    const int N = 1e5 + 10;
                    const int INF = 0x3f3f3f3f;
                    signed main()
                    {
                    	int n;
                    	cin >> n;
                    	int maxn = -INF, minn = INF;
                    	for(int i = 1; i <= n; i++)
                    	{
                    		int x;
                    		cin >> x;
                    		maxn = max(maxn, x);
                    		minn = min(minn, x);
                    	}
                    	cout << minn << " " << maxn << endl;
                    	return 0;
                    }
                    

                    测试点1,测试点6 maxn和minn都一样

                    • -1
                      @ 2022-1-8 11:46:19
                      #include <iostream>
                      #include <math.h>
                      #include <iomanip>
                      using namespace std;
                      #define LL Long Long
                      const int N=1e5+10;
                      const int INF=0x3f3f3f3f;
                      int main()
                      {
                      	int n,x;
                      	cin >> n;
                          int minn , maxx;
                          minn = 10000000;
                          maxx = -1000000;
                      	for(int i = 0 ; i < n ; i++)
                      	{
                      		cin >> x;
                      		if(x > maxx)
                      		{
                      			maxx = x;
                      		}
                      		if(x < minn)
                      		{
                      			minn = x;
                      		}
                      	}
                      	cout << minn << ' ' << maxx << endl;
                      }
                      
                      • -1
                        @ 2022-1-8 11:44:33
                        #include <stdio.h>
                        #include <iostream>
                        #include <math.h>
                        using namespace std;
                        int main()
                        {
                        	int n,x;
                        	cin>>n;
                        	int minn,maxx;
                        	minn=10000000;
                        	maxx=-1000000;
                        	for(int i=0;i<n;i++)
                        	{
                        		cin>>x;
                        		if(x>maxx)
                        		{
                        			maxx=x;
                        		}
                        		if(x<minn)
                        		{
                        		minn=x;
                        		}
                        	}
                        	cout<<minn<<" "<<maxx;
                        }
                        
                        • -1
                          @ 2022-1-8 11:44:05
                          #include <stdio.h>
                          #include <iostream>
                          using namespace std;
                          int main()
                          {
                              int n,x;
                              cin >> n;
                              int minn,maxx;
                              minn = 10000000;
                              maxx = -1000000;
                              for (int i = 0; i < n; i++)
                              {
                                  cin >> x;
                                  if(x > maxx)
                                  {
                                      maxx = x;
                                  }
                                  if (x <minn)
                                  {
                                      minn = x;
                          
                                  }
                          
                          
                              }
                              cout << minn << " " << maxx << endl;
                          }
                          
                          • -2
                            @ 2022-1-8 11:46:40
                            #include <stdio.h>
                            #include <iostream>
                            using namespace std;
                            int main()
                            {
                            	int n,x;
                            	cin >> n;
                            	int minn , maxx;
                            	minn = 10000000;
                            	maxx = -1000000;
                            	for(int i=0; i < n; i++)
                            	{
                            		cin >> x;
                            		if(x >maxx)
                            		{
                            			maxx = x;
                            		}
                            		if(x < minn)
                            		{
                            			minn = x;
                            		}
                            	}
                            	cout << minn << ' ' << maxx << endl;
                            }
                            
                            • 1

                            信息

                            ID
                            982
                            时间
                            1000ms
                            内存
                            128MiB
                            难度
                            5
                            标签
                            递交数
                            702
                            已通过
                            283
                            上传者