继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

小白的C++问题集(lab1)

ARUNNER
关注TA
已关注
手记 3
粉丝 2
获赞 17

被Курочкин折腾的死去活来之后,我终于决定把他的问题总结一下发上来,权当记录自己的血泪。

本文没什么干货,只是一些新手(可能只有我吧QAQ)容易忽视的问题。

1.

char cByte = -12; // cByte == 0x ?    

2.

int iInt = 0xABCDEF98;
unsigned short dd = iInt;// dd == 0x ?
iInt = dd;//iInt == 0x?

short tt = iInt; // tt == 0x?
iInt = tt;               //iInt == 0x?

unsigned int aInt = 0xABCDEF98; 
short ff = aInt; // ff == 0x?
aInt = ff; // aInt == 0x?

unsigned short gg = aInt; // gg == 0x?
aInt = gg; // aInt == 0x?

3.

float fFloat = 4.2533333f;  
double dDouble = 4.2533333; 

if (fFloat == dDouble)
    dDouble = 999;

stop // dDouble == ?

4.

iInt=1;
double dDouble1=iInt/3.f;       
double dDouble2=iInt/3.;       
double dDouble3=(float)iInt/ 3;

if (dDouble1 == dDouble2)
    dDouble1 = 55;

stop // dDouble1 == ?

iInt=1;
double dDouble1=iInt/2.f;       
double dDouble2=iInt/2.;       
double dDouble3=(float)iInt/ 2; 

if (dDouble1 == dDouble2)
    dDouble1 = 55;

stop // dDouble1 == ?

5.

#include  <iostream>        
int nTwin=1;        
namespace TwinSpace{ int nTwin=2;}
main()
{

    nTwin=100;
    TwinSpace::nTwin = 300;
    nTwin++;
    int nTwin;
    nTwin=200;  
    ::nTwin++;  
    {
        int nTwin;
        nTwin=-1;
        {int nTwin = 88;
            {
                nTwin = 99;
            }
        ::nTwin = 44;
            {
            ::nTwin = 91;
            }
        }
        stop // nTwin == ?          ::nTwin == ?
        ::nTwin++;
        TwinSpace::nTwin++;
    }

    nTwin--;
}

6.

for (int i=0; i<3; i++)
    {
        static int nStatic1 = 100;//
        int nLocal1 = 100;
        int nLocal2 = i++;
        static int nStatic2 = ++nStatic1 * (++i);
        nStatic1++;
        nStatic2++;
        nLocal1++;
        stop // i ==  ?
    }

请问总共循环几次,以及全部循环结束后每个值等于多少?

7.

enum eColors
    {
        BLACK,
        BLUE,
        GREEN,
        RED=5,
        YELLOW,
        WHITE=RED+4
    };
int nnn = BLACK;
nnn = BLUE | YELLOW;// nnn == ?
nnn = BLUE + YELLOW;// nnn == ?
nnn = 1 | 6 & BLACK;// nnn == ?
打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP