| |

VerySource

 Forgot password?
 Register
Search
View: 669|Reply: 4

Ask a question, the program runs without error but is always incorrect!

[Copy link]

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-7 10:30:01
| Show all posts |Read mode
#include "stdio.h"
main ()
{
unsigned long x;
int m, y;
scanf ("% d\n",&m);
x = 100;
x >> (m-1);
y = x&&000000000000001;
printf ("y =% d\n",&y);
}


ctrl + f7 is displayed as follows:
-------------------- Configuration: Text2-Win32 Debug --------------------
Compiling ...
Text2.c
D:\c\mxm\Text2.c (8): warning C4552: '>>': operator has no effect; expected operator with side-effect

Text2.obj-0 error (s), 1 warning (s)
Please master guidance, thank you!
Reply

Use magic Report

0

Threads

73

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 Invalid IP Address

Post time: 2020-5-24 19:45:01
| Show all posts
x >> (m-1);
This has no effect.
Do you want to:
x = x >> (m-1)
what?
or:
x >> = (m-1);
Reply

Use magic Report

0

Threads

73

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 Invalid IP Address

Post time: 2020-5-24 20:45:02
| Show all posts
Do n’t even say that I have seen several companies like this kind of face-to-face question:
unsigned int i = 1;
i << 2;
Ask you how many i is now, huh.
Reply

Use magic Report

0

Threads

12

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-5-24 22:45:01
| Show all posts
#include "stdio.h"
void main ()
{
unsigned long;
int m, y;
scanf ("% d",&m);
x = 100;
x = x << m-1;
y = x&000000000000001;
printf ("y =% d\n", y);
}
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-6-10 16:00:01
| Show all posts
I know
Is x>>=(m-1)
&&should be&
...
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list