请哪位c语言高手帮我看一下,并帮我编一个好的程序,谢了

来源:百度知道 编辑:UC知道 时间:2024/06/22 11:02:39
1.用scanf函数输入一个年份year,然后用一个赋值语句计算这一年中2月份的天数datesum,最后用格式输出函数printf输出datesum值。
具体要求如下:(1)所有变量为整型
(2)输入前要有提示
(3)输出结果时要有必要的文字说明
2.由键盘输入一个小于256的十进制整数,然后将该数转换成八位的二进制形式输出。
具体要求如下:
(1)输入前要有提示
(2)若转换成的二进制数不够八位,则在前面添“0”补足八位。例如:十进制数79转换成的二进制数为1001111,但应输出01001111
(3)分别输入十进制数54,96,175,233,255来运行这个程序。

第一道题:
#include <stdio.h>
void main()
{
int i,j;
printf("please input the year:\n");
scanf("%d",&i);
if(i%4==0&&i%100!=0||i%400==0)
{
j=29;
printf("datesum is:%d",j);
}
else
{
j=28;
printf("datesum is:%d",j);
}
getch();
}
第二道题:
#include <stdio.h>
void main()
{
int i,j,x,y,a[8];
printf("please input the number that less than 256:\n");
scanf("%d",&i);
x=i;
for(j=0;j<8;j++)
{
if(x%2==0) a[j]=0;
else a[j]=1;
x=x/2;
}
printf("%d zhuan huan cheng er jin zhi wei:",i);
for(y=7;y>=0;y--)
printf("%d",a[y]);
getch();
}

1.四年一闰,百年不闰,四百年再闰。
#include "stdio.h"
void main()
{
int year,datesum;
scanf("%d",&year);
if(year%4==0&&year%100!=0||year%400==0)