11 solutions

  • 4
    @ 2023-10-4 11:07:29
    #include<iostream>
    #include<iomanip>
    using namespace std;
    int main() {
    	int n,x,y,maxx=0,minn=1001;	 
    	cin>>n;
    	for(int i=1;i<=n;i++){
    	cin>>x;
    	if(x>maxx)
    		maxx=x;
        if(x<minn)
            minn=x;
    	}
        int answer=maxx-minn;
    	cout<<answer;
    	return 0;
    	}
    
    • 1
      @ 2024-7-10 17:11:10
      #include<bits/stdc++.h>
      using namespace std;
      int main(){
      	int n,a,maxn = 0,minn = 10000;
      	cin >> n;
      	for(int i = 1;i <= n;i++){
      		cin >> a;
      		maxn = max(maxn,a);
      		minn = min(minn,a);
      	}
      	cout <<maxn - minn;
      	return 0;
      }
      
      • 1
        @ 2024-3-7 14:42:10
        #include<bits/stdc++.h>
        using namespace std;
        int main(){
        	int t;
        	cin>>t;
        	int a[t];
        	for(int i=0;i<t;i++){
        		cin>>a[i]; 
        	}
        	sort(a,a+t);
        	cout<<a[t-1];
        } 
        
        • 1
          @ 2023-9-19 19:38:59
          #include <bits/stdc++.h>
          using namespace std;
          int main(int argc, char **argv){
          	int n,mx = -1,mn = 1001,x;
          	cin >> n;
          	for (int i = 0;i < n;i++){
          		cin >> x;
          		mx = max(mx,x);
          		mn = min(mn,x);
          	}
          	printf("%d",mx - mn);
          	return 0;
          }
          
          • 1
            @ 2023-9-15 21:37:27

            和上一题一样,大水题一个:

            #include <set>
            #include <ios>
            #include <list>
            #include <cmath>
            #include <ctime>
            #include <queue>
            #include <deque>
            #include <stack>
            #include <vector>
            #include <bitset>
            #include <cctype>
            #include <cerrno>
            #include <cwchar>
            #include <cstdio>
            #include <fenv.h>
            #include <iosfwd>
            #include <string>
            #include <limits>
            #include <math.h>
            #include <cstdlib>
            #include <iomanip>
            #include <clocale>
            #include <complex>
            #include <cstring>
            #include <cstring>
            #include <cwctype>
            #include <istream>
            #include <ostream>
            #include <sstream>
            #include <fstream>
            #include <utility>
            #include <stdio.h>
            #include <iostream>
            #include <stdint.h>
            #include <string.h>
            #include <tgmath.h>
            #include <complex.h>
            #include <algorithm>
            #include <exception>
            #include <stdbool.h>
            #include <stdexcept>
            #include <streambuf>
            #include <functional>
            #include <inttypes.h>
            #include <bits/stdc++.h>
            using namespace std;
            int main(){
            	int n,a,maxn = 0,minn = 10000;
            	cin >> n;
            	for(int i = 1;i <= n;i++){
            		cin >> a;
            		maxn = max(maxn,a);
            		minn = min(minn,a);
            	}
            	cout <<maxn - minn;
            	return 0;
            }
            
            
            • 0
              @ 2024-9-6 19:17:11
              
              #include<iostream>
              #include<queue>
              #include<stack>
              #include<cmath>    
              #include<algorithm> 
              #include<cstring>
              using namespace std;
              int main() 
              {
              	int a,x,y,maxx=0,minn=1010;	 
              	cin>>a;
              	while(a--)
              	{
              		cin>>x;
              		if(x>maxx)
              			maxx=x;
              	    if(x<minn)
              	        minn=x;
              	}
                  int b=maxx-minn;
              	cout<<b;
              	return 0;
              	}
              • 0
                @ 2024-9-3 19:09:03

                #include<bits/stdc++.h> using namespace std; int main(){ int n,min=10000000,max=-10000000,a; cin>>n; for(int i=0;i<=n;i++){ cin>>a; min=a<min? a:min; max=a>max? a:max; } cout<<(max-min);

                return 0; }

                • 0
                  @ 2024-1-31 12:41:48
                  #include<bits/stdc++.h>
                  using namespace std;
                  
                  int main () {
                  	int n,maxx=INT_MIN,minn=INT_MAX; cin >> n;
                  	for (int i = 1; i <= n; i++) {
                  		int t; cin >> t;
                  		maxx = t>maxx?t:maxx;
                  		minn = t<minn?t:minn;
                  	}
                  	cout << maxx-minn;
                  	return 0;
                  }
                  
                  • -1
                    @ 2023-9-26 20:09:40

                    #include #include using namespace std; int main(){ int n,x,maxx=0,maxa=0; cin>>n; for(int i=1;i<=n;i++){ int a; cin>>a; if(a>maxa)maxa=a; } for(int i=1;i<=n;i++){ cin>>x; if(x>maxx)maxx=x; } cout<<maxa-maxx ; return 0; }

                    
                    
                    • -1
                      @ 2023-9-26 19:47:09

                      #include #include using namespace std; int main() { int n,x,maxx=0;

                      cin>>n;
                      for(int i=1;i<=n;i++){
                      
                      
                      
                      cin>>x;
                      
                      if(x>maxx)maxx=x;
                      

                      }

                      cout<<maxx;
                      
                      return 0;
                      

                      }

                      
                      
                      • -4
                        @ 2024-7-10 17:20:26
                        #include <bits/stdc++.h>
                        using namespace std;
                        int main() {
                        
                        	int n,a,b,max=0,min=1001,out;
                        	cin>>n;
                        	for(b=1;b<n+1;b++)
                        	{
                        	cin>>a;
                        	if(a>max)
                        		{
                        	        max=a;
                        		}
                        	if(a<min)
                        		{
                        			min=a;
                        		}
                        	}
                        	out=max-min;
                        	cout<<out;
                        	return 0;
                        }
                        
                        • 1

                        Information

                        ID
                        551
                        Time
                        1000ms
                        Memory
                        256MiB
                        Difficulty
                        4
                        Tags
                        # Submissions
                        215
                        Accepted
                        100
                        Uploaded By