Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <string.h>
- #include <ctype.h>
- #pragma warning(disable:4996)
- typedef long long LL;
- typedef unsigned long long ULL;
- void minmax(int *a, int len, int *max, int *min){
- int i;
- *max = *min = a[0];
- for(i = 0;i < len;i++){
- if(a[i] > *max){
- *max = a[i];
- }
- if(a[i] < *min){
- *min = a[i];
- }
- }
- }
- int main(){
- #ifdef _DEBUG
- FILE *fp = freopen("input.txt", "r", stdin);
- //FILE *fp2 = freopen("output.txt", "w", stdout);
- #endif // _DEBUG
- int t, n, m, M, a[1024] = { 0 }, i;
- scanf("%d", &t);
- while(t--){
- scanf("%d", &n);
- for(i = 0;i < n;i++){
- scanf("%d", a + i);
- }
- minmax(a, n, &M, &m);
- printf("%d\n", M - m);
- }
- #ifdef _DEBUG
- freopen("CON", "r", stdin);
- //freopen("CON", "w", stdout);
- system("pause");
- #endif // _DEBUG
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment