输出中使用 " " (字符串)全AC,使用 ' ' (字符)全WA,请问为何?
查看原帖
输出中使用 " " (字符串)全AC,使用 ' ' (字符)全WA,请问为何?
125507
晴朗2018楼主2022/7/20 23:49

输出中,使用 " " (字符串)和使用 ' ' (字符)效果一致,但使用 " " 全AC,使用 ' ' 全WA。 代码如下:

#include<bits/stdc++.h>
using namespace std;
int n;
void make2(int x)
{
    if(x==2)
    {
        cout<<"2";//这里不能用''
        return;
    }
    if(x==1)
    {
        cout<<"2(0)";
        return;
    }
    bool first=true;
    for(int i=15;i>=0;i--)
    {
        if(x&(1<<i))
        {
            if(!first)
            {
                cout<<"+";//这里不能用''
            }
            else
            {
                first=false;
            }
            if(i==1)
            {
                cout<<"2";//这里不能用''
                continue;
            }
            if(i==0)
            {
                cout<<"2(0)";
                continue;
            }
            cout<<"2(";
            make2(i);
            cout<<")";//这里不能用''
        }
    }
}
int main()
{
    cin>>n;
    make2(n);
    return 0;
}

请问为何?望各路高人指点,谢谢!

2022/7/20 23:49
加载中...