current position:Home>Why did something go wrong and what should I do

Why did something go wrong and what should I do

2022-02-04 16:58:58 CSDN Q & A

img

img

#include<stdio.h>
#include<math.h>
int main()
{
int a,b,c,d;
while(scanf("%d%d %d%d",&a,&b,&c,&d) != EOF)
if(a=c,b=d)
printf("10000");
if(a=c,b=d)
printf("3000");
if(a!=d,b=c&&a=d,b!=c)
printf("1000");
if(a!=b,a!=d,b!=c,b!=d)
printf("none");
return 0;
}




Take the answer :
#include<stdio.h>#include<math.h>int main(){    int a,b,c,d;    while(scanf("%d%d %d%d",&a,&b,&c,&d) != EOF)    {        if(a==b && c==d)        {            printf("10000");            continue;        }        if(a==d && b==c)        {            printf("3000");            continue;        }        if(a == b || a == d || c == b || c == d)        {            printf("1000");            continue;        }        printf("none");    }    return 0;}


Other answers 2:
a=ba==b

These are two different operators


Other answers 3:

First , You can only enter two numbers in one line
then , If the two conditions are met at the same time, use && Connect , At least one satisfaction is used || Connect


Other answers 4:

a=c It's assignment , You want to a and c equal ,a==c


Other answers 5:

To judge equality ==
Logical combination &&
The code is modified as follows :

#include <stdio.h>int main(){    int a,b;    int a1,a2,b1,b2,t;    while(scanf("%d %d",&a,&b) != EOF)    {        a1 = a/10;        a2 = a%10;        b1 = b/10;        b2 = b%10;        if(a==b)            printf("10000\n");        else        {            if(a1 == b2 && a2 == b1)                printf("3000\n");            else if( (a1 == b1 && a2 != b2) || (a1==b2 && a2 != b1) )                printf("1000\n");            else                printf("0\n");        }    }    return 0;}

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/02/202202041658560689.html

Random recommended