杭电acm1106

ps:写了85道水题后,从4w+的排名到了1w+,现在升排名满了许多,AC一道题大概升100+的排名。

sort(a, a+ids+1);这里要+1

#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

int main(void) {
	
	int a[1001], i, flag, ids;
	char s[1001];
	while(scanf("%s", s) != EOF) {

		flag = 0;
		i = 0;
		ids = 0;
		memset(a, 0, sizeof(a));
		
		while(s[i]!='\0') {
			
			if(s[i]=='5')
				flag = 0;
			else {
				if(flag==0) {
					ids ++;
					flag =1;
				}
					
				a[ids] = a[ids] * 10 + (s[i]-'0');
				
 			}
			
			i ++;
		}
		sort(a, a+ids+1);
		for(i=1; i<=ids-1; i++)
			printf("%d ", a[i]);
		printf("%d\n", a[i]);
	}
	
	return 0;
}


posted @ 2015-03-10 11:11  StevenLuke  阅读(157)  评论(0编辑  收藏  举报