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