poj1484 Blowing Fuses

#include
#include
#include

void main(){
	int num,operation_num,max,capacity,curr,i,count=0,total;
	int device_Ampere[30];
	char flag;
	char device_Flag[30];
	scanf("%d %d %d",&num,&operation_num,&capacity);
	while(num != 0 && operation_num != 0 && capacity != 0){
		flag='0';
		max=0;
		total=0;
		for(i=1;i<=num;i++){
			scanf("%d",&device_Ampere[i]);
		}
		memset(device_Flag,'0',sizeof(device_Flag));
		for(i=0;icapacity)
					flag='1';
				if(total>max)
					max=total;
				device_Flag[curr]='1';
			}
			else{
				total-=device_Ampere[curr];
				device_Flag[curr]='0';
			}			
		}
		count++;
		printf("Sequence %d\n",count);	
		if(flag=='1')
			printf("Fuse was blown.\n\n");
		else{
			printf("Fuse was not blown.\n");
			printf("Maximal power consumption was %d amperes.\n\n",max);
		}
		scanf("%d %d %d",&num,&operation_num,&capacity);	
	}
}

你可能感兴趣的:(数据结构与算法)