C语言学习10:

这几天晚自习在书上看到了一个题目,脑子有点乱,模拟了半天都没出结果,索性就回来写了一下;
果然,像我这种脑子不好的,还是写出来比较好……

#include <stdio.h>
main()
{
 int y0,y1,m0,m1,d0,d1;
 char answer;
 
 point1://get the information
 printf("Please enter your birthday:\n");
 printf("Y,M,D");
 putchar ('\n');
 scanf("%d,%d,%d",&y0,&m0,&d0);//enter the birthday
 if (m0>=13||m0<0)
 {printf("error!\nPlease enter right date!");
  goto point1;
 }
 printf("Is this your birthday?\n");
 printf("Please enter \"Y\" to make sure your birthday! \n");//be sure the birthday
 scanf("%s",&answer);
     if (answer=='Y'||answer=='y')
    ;
     else goto point1;

 point2:
 printf("Now please enter the date :\n");
 printf("Y,M,D");
 putchar ('\n');
 scanf("%d,%d,%d",&y1,&m1,&d1);//get the date
 if (m1>=13||m1<0)
 {printf("error!\nPlease enter right date!");
  goto point2;
 }
 
 /*time to calculate*/
 y0=y1-y0;
 if ((d1-d0<=0)||(m1-m0<=0))
 y0--;
 printf("Well your age must be %d ",y0);
 m0=m1-m0;
 m0*=-1;
 d0=d1-d0;
 if (d1-d0<=0)
 m0--;
 d0*=-1;
 printf("And you have left %d years,%d mounth,%d days!",y0,m0,d0);
 putchar('\n');
 
 /*time to judje*/
 printf("Is it right?\n");
 
 scanf("%s",&answer);
 if (answer=='y'||answer=='Y')
 printf("(ノOVO)ノ");//(ノOVO)ノ
 else {printf(":p\n");
      printf("Let's do it again!");
      goto point1;
 }
}
我发现,C语言没办法打颜文字欸……

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值