zoukankan      html  css  js  c++  java
  • poj2876

    简单分型题

    View Code
    #include <iostream>
    #include
    <cstdlib>
    #include
    <cstring>
    #include
    <cstdio>
    using namespace std;

    #define maxn 15

    int n;
    int power[maxn];

    bool is(int a, int p)
    {
    while (p >= 0)
    {
    if (a / power[p] == 1)
    return false;
    a
    %= power[p];
    p
    --;
    }
    return true;
    }

    void work()
    {
    int temp = 1;
    for (int i = 0; i < power[n]; i++)
    {
    if (i >= power[temp] * 3)
    temp
    ++;
    if (is(i, temp))
    putchar(
    '-');
    else
    putchar(
    ' ');
    }
    putchar(
    '\n');
    }

    int main()
    {
    //freopen("t.txt", "r", stdin);
    power[0] = 1;
    for (int i = 1; i <= 12; i++)
    power[i]
    = power[i - 1] * 3;
    while (scanf("%d", &n) != EOF)
    work();
    return 0;
    }
  • 相关阅读:
    Java类加载机制
    DAY18
    DAY17
    DAY16
    DAY15
    DAY14
    DAY13
    DAY12
    DAY11
    DAY10
  • 原文地址:https://www.cnblogs.com/rainydays/p/2174942.html
Copyright © 2011-2022 走看看