DAY I

第一次写博客有点蒙圈,while it's ok,just do it,nothing is impossible to the willing heart.当然其中有很多错误,希望各位看官指出,一起学习,一起进步。
   判断闰年输出1000到2000的闰年,并且输出个数。
代码如下:
#include<stdio.h>
#include<stdlib.h>
int main()
{
 int year, count = 0; //给闰年个数赋初始值0;
 for (year = 1000; year <= 2000; year++)
 if ((year % 4 == 0 && year % 100 != 0 || (year % 400 == 0)))//判断闰年的条件可以被4整除不能被100整除且能被400整除;
 {
  count++;
  printf("%d  ", year);
  if (count % 12 == 0)//闰年的个数满12个后换行
   printf("\n");
 }
 printf("\n");
 printf("输出闰年的个数为%10d\n       ", count);//输出闰年的个数
 system("pause");
 return 0;
}
开始的时候输出结果不清晰,加上一个 if (count % 12 == 0)//闰年的个数满12个后换行 printf("\n");
输出九九乘法口诀表:
代码如下:
#include<stdio.h>
#include<stdlib.h>
int main()
{
 int i, j;
 for (i = 1; i <= 9;i++)
 {
  for (j = 1; j <= i;j++)
   printf("%d*%d=%d   " ,i,j, i*j);//输出i*j的表达式;
   printf("\n");
 }
 system("pause");
 return 0;
}
用VS的朋友可能都会经历输出结果显示闪退的情况,加一个  #include<stdlib.h>和system("pause"); 就好了,不是很明白,应该是停止的指令。




  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值