what wrong with my code?? uva 11364

All about problems in Volume CXIII. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

what wrong with my code?? uva 11364

Postby shopnobaj » Mon Jun 27, 2011 5:44 pm

//uva 11364
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
int num,slot_num,slot[100],i,sum,res,max,min;
scanf("%d",&num);

while(num--)
{
sum=0;
res=0;
max=-1;
min=0;
scanf("%d",&slot_num);
for(i=1;i<=slot_num;i++)
{
scanf("%d",&slot[i]);
if(slot[i]>max)
max = slot[i];
}
//printf("%d\n",max);
sort(slot,slot+i);
//for(j=1;j<=slot_num;j++)
//printf("%d ",slot[j]);
//printf("\n");
min = slot[1];
//printf("%d\n",min);
sum = (max-min);
res = (sum*2);
printf("%d\n",res);
}
return 0;
}
shopnobaj
New poster
 
Posts: 2
Joined: Mon Jun 27, 2011 5:23 pm

Return to Volume CXIII

Who is online

Users browsing this forum: No registered users and 1 guest