Daily brushing title (29)
BASIC-1, is determined leap year
#include<stdio.h>
void f(int n)
{
if(n % 4 == 0 && n % 100 != 0)
printf("yes\n");
else if(n % 400 == 0)
printf("yes\n");
else
printf("no\n");
}
int main()
{
int n;
scanf("%d", &n);
f(n);
return 0;
}
This question is too simple, not specifically explain
BASIC-2,01 string *
This question seems simple, in essence, is a little difficult, and here I offer two solutions
The first scenario, most people can think of is not difficult to find size 01 strings arranged in a binary number can think of, every binary one, that's the essence of
#include<stdio.h>
int main()
{
int a, b, c, d, e;
for(a = 0; a < 2; a++)
for(b = 0; b < 2; b++)
for(c = 0; c < 2; c++)
for(d = 0; d < 2; d++)
for(e = 0; e < 2; e++)
printf("%d%d%d%d%d\n", a, b, c, d, e);
return 0;
}
The second option, more difficult to want to come out, unless you often do problems
#include<stdio.h>
int main()
{
int arr[5] = { 0 };
int k;
int n, j, i;
for(n = 0; n < 32; n++)
{
k = n;
for(i = 0; i < 5; i++)
{
if (k % 2)
arr[i] = 1;
else
arr[i] = 0;
k = k / 2;
}
for(j = 4; j >= 0; j--)
{
printf("%d", arr[j]);
}
printf("\n");
}
return 0;
}
BASIC-3, letters graphics *
Through observation, it was found, has been in A on a diagonal line extending along the other letters A are growing, they are symmetrical about the diagonal line A which, as the number of rows and the same column element will gradually become larger, indicating the absolute value of the element and position related rows and columns. Detailed C code is as follows:
#include<stdio.h>
#include<math.h>
int main()
{
int n, m, i, j;
scanf("%d %d", &n, &m);
char a[n][m];
for(i = 0; i < n; i++)
{
for(j = 0; j < m; j++)
{
printf("%c", 65 + abs(j - i));
}
printf("\n");
}
return 0;
}