c语言-猜生日算法
#include<stdio.h>
int main()
{
int a1[6]={1,3,5,7,9,11};
int a2[6]={2,3,6,7,10,11};
int a3[6]={4,5,6,7,12,0};
int a4[6]={8,9,10,11,12,0};
int b1[4][4]={{1,3,5,7},{9,11,13,15},{17,19,21,23},{25,27,29,31}};
int b2[4][4]={{2,3,6,7},{10,11,14,15},{18,19,22,23},{26,27,30,31}};
int b3[4][4]={{4,5,6,7},{12,13,14,15},{20,21,22,23},{28,29,30,31}};
int b4[4][4]={{8,9,10,11},{12,13,14,15},{24,25,26,27},{28,29,30,31}};
int b5[4][4]={{16,17,18,19},{20,21,22,23},{24,25,26,27},{28,29,30,31}};
int day=0,month=0;
int i,j,answer;
printf("Is your birthday in a1[6]?\n");
for(i=0;i<6;i++)
printf("%5d ",a1[i]);
printf("\n Please input 0 for No and 1 for Yes:");
scanf("%d",&answer);
if(answer==1)
month+=1;
printf("Is your birthday in a2[6]?\n");
for(i=0;i<6;i++)
printf("%5d ",a2[i]);
printf("\n Please input 0 for No and 1 for Yes:");
scanf("%d",&answer);
if(answer==1)
month+=2;
printf("Is your birthday in a3[6]?\n");
for(i=0;i<5;i++)
printf("%5d ",a3[i]);
printf("\n Please input 0 for No and 1 for Yes:");
scanf("%d",&answer);
if(answer==1)
month+=4;
printf("Is your birthday in a4[6]?\n");
for(i=0;i<5;i++)
printf("%5d ",a4[i]);
printf("\n Please input 0 for No and 1 for Yes:");
scanf("%d",&answer);
if(answer==1)
month+=8;
printf("Is your birthday in b1[4][4]?\n");
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
printf("%5d ",b1[i][j]);
printf("\n");
}
printf("\n Please input 0 for No and 1 for Yes:");
scanf("%d",&answer);
if(answer==1)
day+=1;
printf("Is your birthday in b2[4][4]?\n");
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
printf("%5d ",b2[i][j]);
printf("\n");
}
printf("\n Please input 0 for No and 1 for Yes:");
scanf("%d",&answer);
if(answer==1)
day+=2;
printf("Is your birthday in b3[4][4]?\n");
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
printf("%5d ",b3[i][j]);
printf("\n");
}
printf("\n Please input 0 for No and 1 for Yes:");
scanf("%d",&answer);
if(answer==1)
day+=4;
printf("Is your birthday in b4[4][4]?\n");
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
printf("%5d ",b4[i][j]);
printf("\n");
}
printf("\n Please input 0 for No and 1 for Yes:");
scanf("%d",&answer);
if(answer==1)
day+=8;
printf("Is your birthday in b5[4][4]?\n");
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
printf("%5d ",b5[i][j]);
printf("\n");
}
printf("\n Please input 0 for No and 1 for Yes:");
scanf("%d",&answer);
if(answer==1)
day+=16;
printf("\n Your birthday is %d月%d日!\n",month,day);
return 0;
}
c语言-猜生日算法的更多相关文章
- 10个经典的C语言面试基础算法及代码
10个经典的C语言面试基础算法及代码作者:码农网 – 小峰 原文地址:http://www.codeceo.com/article/10-c-interview-algorithm.html 算法是一 ...
- 数据结构C语言版 弗洛伊德算法实现
/* 数据结构C语言版 弗洛伊德算法 P191 编译环境:Dev-C++ 4.9.9.2 */ #include <stdio.h>#include <limits.h> # ...
- 0.数据结构(python语言) 基本概念 算法的代价及度量!!!
先看思维导图: *思维导图有点简陋,本着循循渐进的思想,这小节的知识大多只做了解即可. *重点在于算法的代价及度量!!!查找资料务必弄清楚. 零.四个基本概念 问题:一个具体的需求 问题实例:针对问题 ...
- C语言版数据结构算法
C语言版数据结构算法 C语言数据结构具体算法 https://pan.baidu.com/s/19oLoEVqV1I4UxW7D7SlwnQ C语言数据结构演示软件 https://pan.baidu ...
- java实现猜生日
** 猜生日** 今年的植树节(2012年3月12日),小明和他的叔叔还有小伙伴们一起去植树.休息的时候,小明的同学问他叔叔多大年纪,他叔叔说:"我说个题目,看你们谁先猜出来!" ...
- 用scheme语言实现SPFA算法(单源最短路)
最近自己陷入了很长时间的学习和思考之中,突然发现好久没有更新博文了,于是便想更新一篇. 这篇文章是我之前程序设计语言课作业中一段代码,用scheme语言实现单源最段路算法.当时的我,花了一整天时间,学 ...
- C语言之广度优先算法
广度优先算法又称宽度优先搜索,是一种简便的图的搜索算法之一.搜索方式大致是这样的: 直到搜索到目标结点(结点就是那些圆球球,其中有一个或者多个是目标结点)或者搜完了整个图都没找到目标结点就停止搜索. ...
- C语言qsort函数算法性能测试
对于该算法的复杂性.一个直接的方法是测量的一定量的算法级数据的执行时间的感知. 随着C语言提供qsort对于示例.随着100一万次的数据,以测试其计算量.感知O(nlg(n))时间成本: C码如下面: ...
- 简单的C语言猜数字小游戏
猜数字小游戏可谓是C语言最为基础的一个知识点了,我们可以在此基础上进行延伸,实现随机数的猜测,然后是加入再来一局的模式,等等.这里是抛砖引玉,希望你能做出你的经典之作. #include <st ...
随机推荐
- ubuntu16.04 安装opencv3
(opencvC++) luo@luo-ThinkPad-W540:20181205$ conda install --channel https://conda.anaconda.org/menpo ...
- DNS处理模块dnspython
一.介绍 官网:http://www.dnspython.org/ https://pypi.org/project/dnspython/ dnspython是Python的DNS工具包.它支持几乎所 ...
- sourcetree免注册方法
step1: https://www.sourcetreeapp.com/官网下载windows版软件 step2: 右键-->以管理员身份运行,便安装成功了 step3: 安装好之后会有这么一 ...
- R语言笔记完整版
[R笔记]R语言函数总结 R语言与数据挖掘:公式:数据:方法 R语言特征 对大小写敏感 通常,数字,字母,. 和 _都是允许的(在一些国家还包括重音字母).不过,一个命名必须以 . 或者字母开头, ...
- Exception (2) Java Exception Handling
The Java programming language uses exceptions to handle errors and other exceptional events.An excep ...
- Linux上获取CPU Core个数的实现
Linux上获取CPU Core个数的实现 可以通过多种手段取得CPU Core的个数,如: 1) 调用系统提供的函数get_nprocs(),可以在头文件sys/sysinfo.h中发现它 2) 借 ...
- windows在python基础上安装pip
首先你必须已经安装了python,并且配置好环境 键入pip 复制https://bootstrap.pypa.io/get-pip.py的内容并创建get-pip.py文件(该文件的内容就是刚刚复制 ...
- Linux 下几个重要目录解释
linux下把所有的东西都当作文件的,,一个分区想要使用就需要挂载到一个文件夹上,那这个文件夹就叫挂载点,像常用的把 设备/dev/cdrom挂载到/mnt,,,你想问的应该是linux的各目录的解释 ...
- CentOS7下搭建yum仓库
服务端配置: 1.开启yum缓存 sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf [root@control /]# cat /etc/yum.c ...
- linux安装redis及phpredis环境配置
下载安装包 cd /home/redis/tar wget http://redis.googlecode.com/files/redis-2.4.17.tar.gz tar zxvf redis-2 ...