第一章-问题求解策略-Uva11636-Hello World!

#include<iostream>
using namespace std;
int n,t=1;
int a[1005];
int main()
{
    ios::sync_with_stdio(false);
    a[1]=2;
    for(int i=2;i<=1000;i++)
    {
        a[i]=a[i-1]*2;
    }
    while(cin>>n&&n>0)
    {
        if(n<=1)
        {
            cout<<"Case "<<t++<<": "<<0<<endl;
        }
        else
        {
            for(int i=1;i<=1000;i++)
            {
                if(n>a[i-1]&&n<=a[i])
                {
                    cout<<"Case "<<t++<<": "<<i<<endl;
                }
            }
        }
    }
    return 0;
}
发布了10 篇原创文章 · 获赞 2 · 访问量 2428

猜你喜欢

转载自blog.csdn.net/STL_CC/article/details/104022248