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 ...
随机推荐
- php使用curl 实现GET和POST请求(抓取网页,上传文件),支持跨项目和跨服务器
一:curl 函数和参数详解 函数库:1:curl_init 初始化一个curl会话2:curl_close 关闭一个curl会话3:curl_setopt 为一个curl设置会话参数4:curl_e ...
- Linux系统中当前路径不加入PATH的原因
主要是出于安全的考虑,由于系统默认是允许所有人在/tmp下写入任何文件的,万一有居心不良的用户或者黑客入侵到计算机,并在/tmp下面埋下木马,名字为ls,当用户用root身份登录后,到/tmp目录执行 ...
- 跨版本mysqldump恢复报错Errno1449
已经有一套主从mysql,新增两个slave主库Server version: 5.6.22-log MySQL Community Server (GPL)旧从库Server version: 5. ...
- Java 面试知识点汇总
OOP:(Object Oriented Programming )面向对象编程 重用性.灵活性和扩展性 高内聚.低耦合 面向过程编程与面向对象编程的区别:举例,自己做饭吃与去饭馆吃,去饭馆只需要知道 ...
- Idea安装lombok插件及使用
安装lombok插件:File-settings 具体步骤如下图:1 2.找到Plugins 然后在搜索栏里搜索lombok 点击下放的Search in repositories 3.选中lombo ...
- SpringBoot自定义拦截器实现
1.编写拦截器实现类,此类必须实现接口 HandlerInterceptor,然后重写里面需要的三个比较常用的方法,实现自己的业务逻辑代码 如:OneInterceptor package com ...
- SQL Server 2008 收缩日志
如果SQL SERVER 日志过大,比如,达到了几十个G,想一次性收缩的,直接执行下面命令即可: USE DATABASENAME; GO – Truncate the log by changing ...
- [C++] Variable/Hex conversion
程序编译链接原理预处理:.c -> .i gcc -E hello.c -o hello.i 编译:.i / .c -> .sgcc -S hello.i -o hello.s 汇编:.s ...
- Django中的元类-乾颐堂
看Django(1.6)的Form相关源代码时比较迷惑,于是节选了django.forms.forms.py中的几个代码片段来分析Django中是怎么使用元类的: 1 2 3 4 5 6 7 8 9 ...
- Java知多少虚拟机(JVM)以及跨平台原理
相信大家已经了解到Java具有跨平台的特性,可以“一次编译,到处运行”,在Windows下编写的程序,无需任何修改就可以在Linux下运行,这是C和C++很难做到的. 那么,跨平台是怎样实现的呢?这就 ...