文章

1

粉丝

0

获赞

6

访问

239

头像
1234数的组合 题解:不是,为什么ac不了
P5254 湖北工业大学机试题
发布于2025年3月23日 10:06
阅读数 239

#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

using namespace std;

const int N = 1010;


int main()
{
    std::ios::sync_with_stdio(false);
    int w[N];
    int cnt = 0;
    cout << 64 << endl;
    printf("1\n2\n3\n4\n12\n13\n14\n21\n23\n24\n31\n32\n34\n41\n42\n43\n");
    string s = "123";
    do
    {
        w[cnt++] = (s[0] - '0') * 100 + (s[1] - '0') * 10 + (s[2] - '0'); 
    } while (next_permutation(s.begin(), s.end()));
    s = "124";
    do
    {
        w[cnt++] = (s[0] - '0') * 100 + (s[1] - '0') * 10 + (s[2] - '0'); 
    } while (next_permutation(s.begin(), s.end()));
    s = "134";
    do
    {
        w[cnt++] = (s[0] - '0') * 100 + (s[1] - '0') * 10 + (s[2] - '0'); 
    } while (next_permutation(s.begin(), s.end()));
    s = "234";
    do
    {
        w[cnt++] = (s[0] - '0') * 100 + (s[1]...
登录查看完整内容


登录后发布评论

1 条评论
快乐小土狗
2025年3月23日 15:41

printf改为cout

cout << "1\n2\n3\n4\n12\n13\n14\n21\n23\n24\n31\n32\n34\n41\n42\n43\n";

printf和cout尽量不要混用

赞(1)