HDOJ1014水题格式输出

来源:互联网 发布:淘宝房产司法拍卖入口 编辑:程序博客网 时间:2024/06/06 07:49
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string.h>
#include<math.h>
#define inf 0x3f3f3f
using namespace std;
__int64 res;
int n,s,d,vis,f;
bool a[100000];
int main()
{
    f = 0;
    while(scanf("%d%d",&s,&d) != EOF)
    {
        if(f == 1)printf("\n");
        n = 0;
        memset(a,0,sizeof(a));
        vis = 0;
        while(a[n] == 0)
        {
            vis++;
            a[n] = 1;
            n = (n + s)%d;
        }
        if(vis == d)printf("%10d%10d    Good Choice\n\n",s,d);
        else printf("%10d%10d    Bad Choice\n\n",s,d);
        //f = 1;
    }
    return 0;

}

这里学习了格式输出%xd表示右顶格总共占X个位置,左顶格是-x

在C++里面通过调用头文件inmanip.h然后cou<<set(x)<<a<<endl;来表示输入占X个位置。右对齐

原创粉丝点击