
当m!=n的时候,码闹就一定能汇合嘛?如果不行,不就是死循环了嘛?
试试这个迹举看迟州罩...
#include<stdio.h>void main(void)
{
int x,y,m,n,L
scanf("%d%d%d%d%d",&x,&y,&m,&n,&L)
if(x<y){
if(m>n)
{
if((y-x)%(m-n)==0)
printf("%d\n",(y-x)/(m-n))
else
printf("Impossible\n")
}
else if(m<n)
{
if((L-(y-x))%(n-m)==0)
printf("%d\n",(L-(y-x))/(n-m))
else
printf("Impossible\n")
}
else
{
printf("Impossible\n")
}
}
else
{
if(m>n)
{
if((L-(x-y))%(m-n)==0)
printf("%d\n",(L-(x-y))/(m-n))
else
printf("Impossible\n")
}
else if(m<n)
{
if((x-y)%(n-m)==0)
printf("%d\n",(x-y)/(n-m))
else
printf("Impossible\n")
}
else
{
printf("Impossible\n")
}
}
}
#include <stdlib.h>枯高答#include <stdio.h>
#include <string.h>
#define COL 5
char left[3][COL],right[3][COL],result[3][COL]
char arr[13]="ABCDEFGHIJKL"
int lighter(char c) {
int i
for(i=0i<3i++) {
if(result[i][0]=='e') {
if(!strchr(left[i],c) != !strchr(right[i],c)) return 0
}
if(result[i][0]=='u') {
if(!strchr(right[i],c)) return 0
}
if(result[i][0]=='h') {
if(!strchr(left[i],c)) return 0
}
}
return 1
}
int heavier(char c) {
int i
for(i=0i<3i++) {
if(result[i][0]=='e') {
if(!strchr(left[i],c) != !strchr(right[i],c)) return 0
}
if(result[i][0]=='h') {
if(!strchr(right[i],c)) return 0
}
if(result[i][0]=='u') {
if(!strchr(left[i],c)) return 0
}
}
return 1
}
int main() {
int i
while(1) {
memset(left,'\0',3*COL)
memset(right,'\0',3*COL)
memset(result,'\0',3*COL)
for(i=0i<3i++) {
scanf("%s %s %s",left[i],right[i],result[i])
}
for(i=0i<没慧12i++) {
if(lighter(arr[i])) {
printf("%c is the counterfeit coin and it is lighter\n",arr[i])
break
}
else printf("%c is not the counerfeit coin\n",arr[i])
if(heavier(arr[i])) {
printf("念隐%c is the counterfeit coin and it is heavy\n",arr[i])
break
}
}
}
return 1
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)