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 ...
随机推荐
- [C++] const object
const object const 对象只能调用const函数 const函数不能改变一般成员变量的值,但是mutable的变量不受限制
- LWIP带UCOS操作系统移植
LWIP支持RAW.NETCONN.SOCKET这三种编程接口,后两者必须有操作系统来支持的:LWIP带操作系统的移植很重要!!
- 下拉菜单--JavaScript触发方法
1. $(function(){ $(".dropdown-toggle").one("click",function(){ $(this).dropdown( ...
- CentOS7 安装Maven3
下载安装文件 cd /root wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.3.9/binaries/apache- ...
- Actor模型文章收集
参与者模式——维基百科 Akka.Net——github开源项目 Actor原理——比较深入的文章
- 洛谷P4149 [IOI2011]Race(点分治)
题目描述 给一棵树,每条边有权.求一条简单路径,权值和等于 KK ,且边的数量最小. 输入输出格式 输入格式: 第一行:两个整数 n,kn,k . 第二至 nn 行:每行三个整数,表示一条无向边的 ...
- Dubbo RPC源码解读
https://yq.aliyun.com/articles/272405#27 本文代码摘录的时候,将一些与本流程无关的内容去掉了,如有需要请看源码. 一.闲言碎语 使用rpc框架已经多年了,虽然之 ...
- 所有中心对称五字母域名生成,扫了一下,com的基本上都被注册了。。。
public static void main(String[] args) { String[] letter = new String[]{"i","m", ...
- jQuery获取各种input输入框的值
1.获取一组radio单选框的值(name属性为一组的radio的name属性) var q1 = $("input[name=element_name]:checked").va ...
- Shapefile点图层转换为Shapefile线图层
在Oracle数据表转换为Shapefile(一)和Oracle数据表转换为Shapefile(二)两篇文章中,分别介绍了两种不同的根据Oracle数据表生成Shapefile点图层的方法.本文在此基 ...