17 条题解

  • 2
    @ 2022-1-15 15:11:05
    #include <stdio.h>
    #include <iostream>
    using namespace std;
    int main()
    {
    	int n,a,b=-1,c=1001;
    	cin>>n;
    	for(int i=1;i<=n;i++)
    	{
    		cin>>a;
    		if(b<a)
    		{
    			b=a;	
    		}
    		if(c>a)
    		{
    			c=a;
    		}
    	}
    	cout<<b-c;
    }
    
    • 1
      @ 2024-12-14 20:07:10
      #include <queue>
      #include <math.h>
      #include <stack>
      #include <stdio.h>
      #include <iostream>
      #include <vector>
      #include <iomanip>
      #include <string.h>
      #include <algorithm>
      #include <bitset>
      #include <cctype>
      #include <cerrno>
      #include <clocale>
      #include <complex>
      #include <cstdlib>
      #include <ctime>
      #include <deque>
      #include <exception>
      #include <fstream>
      #include <functional>
      #include <limits>
      #include <list>
      #include <map>
      #include <ios>
      #include <iosfwd>
      #include <set>
      #include <sstream>
      #include <stdexcept>
      #include <streambuf>
      #include <utility>
      #include <cwchar>
      #include <cwctype>
      using namespace std;
      #define int long long
      #define void inline void
      queue<int> Q;
      stack<int> S;
      vector<int> V;
      #ifndef SOMETHING_H
      #define SOMETHING_H
      #endif
      inline int read(){
      	int x = 0, f = 1;
      	char c = getchar();
      	while(c < '0'  ||  c > '9'){
      		if(c == '-')
      			f = -1;
      		c = getchar();
      	}
      	while(c >= '0'  &&  c <= '9'){
      		x = x * 10 + c - 48;
      		c = getchar();
      	}
      	return x * f;
      }
      int n, a[30000001], maxn = -2100000000, minn = 2100000000;
      void Main(){
      	n = read();
      	for(int i = 1; i <= n; i++)
      		a[i] = read();
      	for(int i = 1; i <= n; i++){
      		if(a[i] > maxn)
      			maxn = a[i];
      		if(a[i] < minn)
      			minn = a[i];
      	}
      	printf("%lld\n", maxn - minn);
      	return;
      }
      signed main(){
      	Main();
      	return 0;
      }
      
      • 0
        @ 2024-12-22 10:40:33

        #include<bits/stdc++.h> using namespace std; int main() { int a,b,max = -1,min = 999999, ans; //gfhghfdhbhd cin >> a; for(int i = 1;i <= a ;i++){ cin >> b; if(b > max) max = b; if(b < min) min = b; } cout << max - min; return 0; }

        • 0
          @ 2023-3-29 19:36:15
          /**************************************************************/
          #include
          using namespace std;
          long long n,x,maxn=-1000,minn=1000;
          int main(){
          	cin>>n;
          	for(int i=1;i<=n;i++){
          		cin>>x;
          		maxn=max(maxn,x);
          		minn=min(minn,x);
          	}
          	cout<<maxn-minn;
          	return 0;
          }
          
          • -1
            @ 2024-3-18 21:19:02
            //#include <bits/stdc++.h> 
            #include <iostream>
            #include <stdio.h>
            #include <math.h>
            #include <iomanip>
            using namespace std;
            const int N = 1e5 + 10;
            const int INF = 0x3f3f3f3f;
            int n , a , x , d , cha;
            int main()
            {
            	cin >> n;
            	for( int i = 1 ; i <= n ; i++ )
            	{
            		cin >> a;
            		if( i == 1 )
            		{
            			d = a;
            			x = a;
            			continue;
            		}
            		if( a < x )
            		{
            			x = a;
            		}
            		if( a > d )
            		{
            			d = a;
            		}
            	}
            	cha = d - x;
            	cout << cha; 
                return 0;
            }
            
            • -1
              @ 2023-12-5 21:56:22

              用的数组+for做的

              #include<bits/stdc++.h>
              using namespace std;
              int main(){
              	int n=0,i=1;
              	cin>>n;
              	int a[n+1];
              	for(int i=1;i<=n;i++){
              		cin>>a[i];
              	}
              	int max=a[1],min=a[1];
              	for(i=1;i<=n;i++){
              		if(a[i]>max){
              			max=a[i];
              		}
              		if(a[i]<min){
              			min=a[i];
              		}
              	}
              	cout<<max-min;
              	return 0;
              }
              
              • -1
                @ 2023-7-12 22:32:34

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

                • -1

                  本来想用冷门词unsigned解这道题的,结果它丝毫不争气,无奈用回int 终于知道unsigned为什么冷门了。。 各位大佬如果知道用它怎么解,请告诉我吧!🎉️

                  AC代码:

                  #include<stdio.h>
                  #include<iostream>
                  #include<math.h>
                  using namespace std;
                   int a;
                   int n,maxx=0,minx=100000000;
                  int main()
                  {
                  	cin>>n;
                  	for(int i=1;i<=n;i+=1)
                  	{
                  		cin>>a;
                  		if(a<0)
                  		{
                  			continue;
                  		}
                  		maxx=max(maxx,a);
                  		minx=min(minx,a);
                  	}
                  	cout<<maxx-minx;
                  }
                  
                  
                  • -1
                    @ 2023-3-31 20:46:31

                    #include<bits/stdc++.h> using namespace std; int main() { int n,x,m=-1000,m1=1000; cin>>n; for(int i=1; i<=n; i++) { cin>>x; m=max(m,x); m1=min(m1,x); } cout<<m-m1; return 0; }

                    • -1
                      @ 2023-3-29 19:36:18

                      #include <stdio.h> #include <iostream> using namespace std; int n,a,maxx=-1000,minn=1000; int main(){ cin >> n; for( int i=1; i<=n ; i++){ cin >> a; maxx = max(a,maxx); minn= min(a, minn); } cout << maxx-minn;

                      1. }
                      • -1
                        @ 2022-12-20 22:08:44

                        水。。。 AC代码:

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

                        点个赞吧!

                        • -1
                          @ 2022-1-15 10:28:43
                          #include <stdio.h>
                          #include <iostream>
                          using namespace std;
                          int main()
                          {
                          	int n,a,b=-1,c=1001;
                          	cin>>n;
                          	for(int i=1;i<=n;i++)
                          	{
                          		cin>>a;
                          		if(b<a)
                          		{
                          			b=a;	
                          		}
                          		if(c>a)
                          		{
                          			c=a;
                          		}
                          	}
                          	cout<<b-c;
                          }
                          
                          • -1
                            @ 2022-1-8 15:23:25
                            #include<iostream>
                            using namespace std;
                            int main()
                            {
                                int n,a[1001];
                                int min=9999,max=0;
                                int i;
                                cin>>n;
                                for(i=1; i<=n; i++)
                                {
                                    cin>>a[i];
                                    if(a[i]>max)
                                        max=a[i];
                                    if(a[i]<min)
                                        min=a[i];
                                }
                            
                                cout<<max-min<<endl;
                                return 0;
                            }
                            
                            • -2
                              @ 2023-3-9 22:40:24
                              #include <stdio.h>
                              #include <iostream>
                              using namespace std;
                              int main()
                              {
                              	int n,a,b=-1,c=1001;
                              	cin>>n;
                              	for(int i=1;i<=n;i++)
                              	{
                              		cin>>a;
                              		if(b<a)
                              		{
                              			b=a;	
                              		}
                              		if(c>a)
                              		{
                              			c=a;
                              		}
                              	}
                              	cout<<b-c;
                              }
                              
                              • -2
                                @ 2022-12-24 20:12:39

                                水题 #include《~~~~iostream》 using namespace std; int n,x,_max=-10000,_min=10000; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>x; _max=max(_max,x); _min=min(_min,x); } cout<<_max-_min; } 求赞

                                • -2
                                  @ 2022-10-25 13:23:10
                                  #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 << maxn - minn  << endl;
                                  	return 0;
                                  }
                                  

                                  嗯……

                                  • -2
                                    @ 2022-10-15 20:19:34

                                    #include<iostream>

                                    using namespace std;

                                    int main() { int n;

                                    int a; 
                                    
                                    int max =- 1;
                                    
                                    int i;
                                    
                                    int min = 1001;
                                    
                                    cin >> n;
                                    
                                    for (i = 1; i <= n; i ++)
                                    {	
                                    	cin >> a;
                                    
                                    	if(a > max)
                                    	{	
                                    		
                                    		max = a;
                                           
                                        }
                                    
                                    	if(a < min)
                                    	{
                                    	
                                    		min = a; 
                                    
                                        }
                                    
                                    }
                                    
                                    cout << max - min;
                                    
                                    return 0;
                                    

                                    }

                                    • 1

                                    信息

                                    ID
                                    978
                                    时间
                                    1000ms
                                    内存
                                    128MiB
                                    难度
                                    3
                                    标签
                                    递交数
                                    704
                                    已通过
                                    358
                                    上传者