| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
大家看看我这哪里错了?#include <stdio.h> #include <stdlib.h> int lengthofLoad, numofArea; int * start,* end; void main(int argc, char *argv) { int i = 0; int result; scanf("%d %d",&lengthofLoad,&numofArea); if(numofArea <= 0 || lengthofLoad <= 0) { return; } start = (int *)malloc(sizeof(int)*numofArea); end = (int *)malloc(sizeof(int)*numofArea); while(i < numofArea) { scanf("%d %d",&start[i],&end[i]); i++; } result = NumofTree(); printf("%d\n",result); } int NumofTree() { char *trees = (char*)calloc(lengthofLoad, sizeof(char)); int i = 0, j = 0; for(;i < numofArea; i++) { j = start[i]; for(;j <= end[i]; j++) trees[j] = '1'; } j = 0; for(i = 0; i<lengthofLoad; i++) if(trees[i] == '1') j++; return lengthofLoad - j + 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator