---
title: "九度OJ 题目1032：ZOJ"
author: "piperzero"
date: "2013-02-03T07:22:00Z"
tags: []
slug: "oj-1032-zoj"
draft: false
lastmod: "2013-03-06T20:51:29Z"
id: 1825049
url: "https://piperzero.iteye.com/blog/1825049"
---

```
/********************************* 
 *    日期：2013-2-3
 *    作者：SJF0115 
 *    题号: 九度OJ 题目1032：ZOJ
 *    来源：http://ac.jobdu.com/problem.php?pid=1032
 *    结果：AC 
 *    来源：2009年浙江大学计算机及软件工程研究生机试真题
 *    总结：
**********************************/ 
#include<stdio.h>
#include<string.h>

int main(){
	int i,ZCount,OCount,JCount;
	char string[1000];
	//freopen("C:\\Users\\SJF\\Desktop\\acm.txt","r",stdin); 
	while(scanf("%s",string) != EOF && strcmp(string,"E") != 0){
		ZCount = 0,OCount = 0,JCount = 0;
		//统计ZOJ字符的个数
		for(i = 0;i < strlen(string);i++){
			if(string[i] == 'Z'){
				ZCount ++;
			}
			else if(string[i] == 'O'){
				OCount ++;
			}
			else if(string[i] == 'J'){
				JCount ++;
			}
		}
		//按ZOJ的顺序输出
		for(i = 0;i < ZCount || i < OCount || i < JCount;i++){
			if(i < ZCount){
				printf("Z");
			}
			if(i < OCount){
				printf("O");
			}
			if(i < JCount){
				printf("J");
			}
		}
		printf("\n");
	}
}
```