8 solutions

  • 3
    @ 2024-11-16 21:55:41

    C++ 中可以使用 %8d输出空 88 格。

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        printf("%8d %8d %8d",a,b,c);
        return 0;
    }
    
    
    • @ 2024-11-30 20:23:33

      #include #include<bits/stdc++.h> using namespace std; int main() { int a,b,c; cin>>a>>b>>c; cout<<setw(8)<<a<<" "<<setw(8)<<b<<" "<<setw(8)<<c<<endl; return 0; }

  • 2
    @ 2025-1-26 20:30:00

    这题可以使用setw()函数。

    #include <iostream>
    #include <iomanip>
    using namespace std;
    int main()
    {
      int a, b, c;
      cin >> a >> b >> c;
      cout << setw(8) << a << " " << setw(8) << " " << setw(8) << b << " " << setw(8) << c << endl;
      return 0;
    }
    

    也可以使用printf()函数。

    #include <cstdio>
    int main()
    {
      int a, b, c;
      scanf("%d %d %d", &a, &b, &c);
      printf("%8d %8d %8d\n", a, b, c);
      return 0;
    }
    • 2
      @ 2024-12-3 13:01:08

      #include<bits/stdc++.h> using namespace std; int main(){ int a,b,c; cin>>a>>b>>c; printf("%8d %8d %8d",a,b,c); return 0; }

      • 1
        @ 2025-9-20 13:51:01

        #include #include // 这个头文件提供了设置输出格式的功能 using namespace std;

        int main() { // 定义三个变量,用来存储输入的三个整数 int a, b, c;

        // 从键盘读入三个整数,用空格分开
        cin >> a >> b >> c;
        
        // 按要求输出:每个数占8个字符宽度,右对齐,中间用空格隔开
        // setw(8) 就是设置宽度为8个字符的意思
        cout << setw(8) << a << " " 
             << setw(8) << b << " " 
             << setw(8) << c;
        
        return 0;
        

        }

        • 1
          @ 2025-4-20 18:50:30

          万能头文件+setw()函数

          #include<bits/stdc++.h>
          using namespace std;
          int main(){
              int a,b,c;
              cin>>a>>b>>c;
              cout<<setw(8)<<a<<setw(8)<<b<<setw(8)<<c;
              return 0;
          }
          
          • 0
            @ 2025-10-26 10:32:10

            #include int a, b, c; int main() { scanf("%d%d%d", &a, &b, &c); printf("%d", b); return 0; }

            • -8
              @ 2024-12-3 12:57:41

              哇哦!(‘~’)

              • -12
                @ 2024-11-28 16:57:55

                fdfvddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddcaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

                • 1

                Information

                ID
                4454
                Time
                1000ms
                Memory
                128MiB
                Difficulty
                1
                Tags
                (None)
                # Submissions
                1044
                Accepted
                374
                Uploaded By