08/02/12 15:32:39
>>192
課題1
#include <stdio.h>
int main(void)
{
bool exist[10000]={false,};
int temp,i=0,max,min,count=0;
FILE *fp=fopen("input8500.txt","r");
if(!fp) return 1;
while(!feof(fp)){
fscanf(fp,"%d ",&temp);
exist[temp]=true;
}
fclose(fp);
while(!exist[i++]);
min = i;
i = 9999;
while(!exist[i--]);
max = i;
for(i = 0; i < 10000;i++) if(exist[i])count++;
printf("count = %d\nmax - min = %d",count,max-min);
return 0;
}