ZOJ3479 测试数据过了,提交是WA. http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4276求解
#include<string.h>#include<stdio.h>#defineZODIAC12#defineTHISYEAR"Rabbit"charz[][ZODI...
#include<string.h>
#include<stdio.h>
#define ZODIAC 12
#define THISYEAR "Rabbit"
char z[][ZODIAC] = {"pig", "Dog", "Rooster", "Monkey", "Ram", "Horse", "Snake", "Dragon", "Rabbit", "Tiger", "Ox", "Rat"};
int getPosition(char year[],int age){
int i;
for(i=0;i<ZODIAC;i++){
if(strcmp(year,*(z+i))==0)
break;
}
if(age%ZODIAC-1+i>=ZODIAC){
i = age%ZODIAC-1+i-ZODIAC;
return i;
}
else
return i+age%ZODIAC-1;
}
int main(){
int n,i;
scanf("%d",&n);
if(n>1000||n<0)
n=1000;
int intArray[n];
for(i=0;i<n;i++){
scanf("%d",&intArray[i]);
if(intArray[i]>200||intArray[i]<1)
intArray[i] = 200;
}
for(i=0;i<n;i++){
printf("%s\n",*(z+getPosition(THISYEAR,intArray[i])));
}
return 0;
}
求牛人找出错误...感谢啊 。。。。最近没分,有分一定追加。。。 展开
#include<stdio.h>
#define ZODIAC 12
#define THISYEAR "Rabbit"
char z[][ZODIAC] = {"pig", "Dog", "Rooster", "Monkey", "Ram", "Horse", "Snake", "Dragon", "Rabbit", "Tiger", "Ox", "Rat"};
int getPosition(char year[],int age){
int i;
for(i=0;i<ZODIAC;i++){
if(strcmp(year,*(z+i))==0)
break;
}
if(age%ZODIAC-1+i>=ZODIAC){
i = age%ZODIAC-1+i-ZODIAC;
return i;
}
else
return i+age%ZODIAC-1;
}
int main(){
int n,i;
scanf("%d",&n);
if(n>1000||n<0)
n=1000;
int intArray[n];
for(i=0;i<n;i++){
scanf("%d",&intArray[i]);
if(intArray[i]>200||intArray[i]<1)
intArray[i] = 200;
}
for(i=0;i<n;i++){
printf("%s\n",*(z+getPosition(THISYEAR,intArray[i])));
}
return 0;
}
求牛人找出错误...感谢啊 。。。。最近没分,有分一定追加。。。 展开
1个回答
展开全部
#include <stdio.h>
int main()
{
char z[12][20] = {"Pig", "Dog", "Rooster", "Monkey",
"Ram", "Horse", "Snake", "Dragon",
"Rabbit", "Tiger", "Ox", "Rat"};
int i,n,j;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&j);
printf("%s\n",z[(j+7)%12]);
}
return 0;
}
int main()
{
char z[12][20] = {"Pig", "Dog", "Rooster", "Monkey",
"Ram", "Horse", "Snake", "Dragon",
"Rabbit", "Tiger", "Ox", "Rat"};
int i,n,j;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&j);
printf("%s\n",z[(j+7)%12]);
}
return 0;
}
更多追问追答
追问
不对,题目写了输入一个就输出结果吗???
追答
ACM的输出和输出是分开的,你程序递交编译了以后,有一个文件会给程序输入数据,然后程序的输出会保存到另一文件里。系统就比对你的输出和标准输出是不是一样的。如果一样,则程序就是对的。
所以程序可以保存所有输出,在最后一起输出,也可以输入一个就输出一个,两种都可以的。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询