zcmu-1151 搭数字Ⅱ(找规律题)

题目链接 

相似题目链接(zcmu-1150 搭数字Ⅰ(找规律题))

这个规律比上面更容易

#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;


int main()
{
    int n,x;
    while(cin>>n)
    {
       if(n % 2 == 0)
       {
           x = n / 2;
           while(x--)
               cout<<1;
       }
       else {
           x = (n - 3) / 2;
           cout<<7;
           while(x--)
               cout<<1;
       }
        cout<<endl;
        
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/hzyhfxt/article/details/81975415