首页 > 其他分享 >HDOJ 2051-2060

HDOJ 2051-2060

时间:2023-03-03 19:11:40浏览次数:41  
标签:2051 case int number base each 2060 Input HDOJ

2050Bitset

Problem Description Give you a number on base ten,you should output it on base two.(0 < n < 1000)   Input For each case there is a postive number n on base ten, end of file.   Output For each case output a number on base two.   Sample Input 1 2 3   Sample Output 1 10 11 人话:十进制转二进制
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int a[16];
    int i, j;
    while (scanf("%d", &n) != EOF)
    {
        i = 0;
        while (n > 0)
        {
            a[i] = n % 2;
            n = n / 2;
            i++;
        }
        for (j = i - 1; j >= 0; j--)
            printf("%d", a[j]);
        printf("\n");
    }
}

 


2052Picture

Problem Description Give you the width and height of the rectangle,darw it.

 

Input Input contains a number of test cases.For each case ,there are two numbers n and m (0 < n,m < 75)indicate the width and height of the rectangle.Iuput ends of EOF.   Output For each case,you should draw a rectangle with the width and height giving in the input.
after each case, you should a blank line.   Sample Input 3 2

 

Sample Output +---+ |   | |   | +---+

 

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int w, h;
    int i, j;
    while (scanf("%d %d", &w, &h) != EOF)
    {
        cout << "+";
        for (i = 0; i < w; i++)
            printf("-");
        cout << "+" << endl;

        for (i = 0; i < h; i++)
        {
            cout << "|";
            for (j = 0; j < w; j++)
                printf(" ");
            cout << "|" << endl;
        }

        cout << "+";
        for (i = 0; i < w; i++)
            printf("-");
        cout << "+" << endl;
    }
}

 

 

 

 

 

 

 

 

 

 

标签:2051,case,int,number,base,each,2060,Input,HDOJ
From: https://www.cnblogs.com/elegantcloud/p/17176679.html

相关文章

  • AD52060兼容替代TPA3110,AD52050兼容替代TPA3136
    AD52060是一款高效立体声D类功放,它的供电范围较宽(8V~26V),能方便地与各型电源板,包括LED液晶电源板、电源高压二合一板等相连接;输出功率较大,在供电为24V的状态下,输出功率可......
  • HDOJ2097 Sky数
    Sky数TimeLimit:1000/1000MS(Java/Others)    MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):25391    AcceptedSubmission(s):14419P......
  • HDOJ2096 小明A+B
    小明A+BTimeLimit:1000/1000MS(Java/Others)    MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):46410    AcceptedSubmission(s):21882......
  • HDOJ2095 find your present (2)
    findyourpresent(2)TimeLimit:2000/1000MS(Java/Others)    MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):25477    AcceptedSubmiss......
  • HDOJ2094 产生冠军
    产生冠军TimeLimit:1000/1000MS(Java/Others)    MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):18681    AcceptedSubmission(s):8468......
  • HDOJ2006求奇数的乘积
    求奇数的乘积TimeLimit:2000/1000MS(Java/Others)    MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):103371    AcceptedSubmission(s):......
  • HDOJ2007 平方和与立方和
    平方和与立方和TimeLimit:2000/1000MS(Java/Others)    MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):185838    AcceptedSubmission(s)......
  • HDOJ2093 考试排名
    考试排名TimeLimit:1000/1000MS(Java/Others)    MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):16041    AcceptedSubmission(s):5604......
  • HDOJ2014 青年歌手大奖赛_评委会打分
    青年歌手大奖赛_评委会打分TimeLimit:2000/1000MS(Java/Others)    MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):95015    AcceptedSub......
  • HDOJ2016 数据的交换输出
    数据的交换输出TimeLimit:2000/1000MS(Java/Others)    MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):113095    AcceptedSubmission(s)......