快捷搜索:  汽车  科技

算卦怎么能成为高手(业余自学编程第二十五天编写一个周易摇卦程序)

算卦怎么能成为高手(业余自学编程第二十五天编写一个周易摇卦程序){int main()#include<stdio.h>#include<stdlib.h>#include<time.h>

今天用我精深的小学数学知识乘法除法和加法,和最近自学的c基础知识写了一个摇卦的程序,也可以说是一个抽奖程序,不过这个程序还有两个问题,第一输出顺序不对,了解易经的人都知道卦是从下往上看的,

但是这个程序是从上往下看的,还有就是不知道怎么按一次出现三个随机数,所以只能一个一个摇,但是易经是三枚硬币一起摇的,所以程序总体上还是有所欠缺的,但是不妨碍使用,附上用法和源码,用的时候不能连续按,否则都是一样的数字,所以用的时候要平心静气,闭上眼睛,想着心中所想之事,然后根据心情来按,亲测很准(瞎说的,权当娱乐);

突然想到,网游中的掉落是不是也是这么写的?

源码如下

#include<stdio.h>

#include<stdlib.h>

#include<time.h>

int main()

{

int a b c i j k t=0;

for (i = 0; i < 6; i )//这里是一共出了六个爻

{

b = 0;

for (j = 0; j < 3; j )//这里是摇三个硬币,出一个爻

{

srand((unsigned)time(NULL));

a = rand() % 2;

if (a == 0)

c = 2;

else c = 1;

b = b c;

b = b * 10;

getchar();

}

b = b / 10;

printf("%d\t" b);

switch (b)

{

case 122:printf("- -\n"); k = 2; break;

case 212:printf("- -\n"); k = 2; break;

case 221:printf("- -\n"); k = 2; break;

case 112:printf("-\n"); k = 1; break;

case 121:printf("-\n"); k = 1; break;

case 211:printf("-\n"); k = 1; break;

case 111:printf("-O\n"); k = 1; break;

case 222:printf("- -X\n"); k = 2; break;

default:printf("cuowu1\n");

}

t = k t;

t = t * 10;

}

t = t / 10;

switch (t)

{

case 111111:printf("\n乾为天\n"); break;

case 111112:printf("\n泽天阙\n"); break;

case 111121:printf("\n火天大有\n"); break;

case 111122:printf("\n雷天大壮\n"); break;

case 111211:printf("\n风天小畜\n"); break;

case 111212:printf("\n水天需\n"); break;

case 111221:printf("\n山天大畜\n"); break;

case 111222:printf("\n地天泰\n"); break;

case 112111:printf("\n天泽履\n"); break;

case 112112:printf("\n兑为泽\n"); break;

case 112121:printf("\n火泽睽\n"); break;

case 112122:printf("\n雷泽归妹\n"); break;

case 112211:printf("\n风泽中孚\n"); break;

case 112212:printf("\n水泽杰\n"); break;

case 112221:printf("\n山泽损\n"); break;

case 112222:printf("\n地泽临\n"); break;

case 121111:printf("\n天火同人\n"); break;

case 121112:printf("\n泽火革\n"); break;

case 121121:printf("\n离为火\n"); break;

case 121122:printf("\n雷火峰\n"); break;

case 121211:printf("\n风火家人\n"); break;

case 121212:printf("\n水火既济\n"); break;

case 121221:printf("\n山火贲\n"); break;

case 121222:printf("\n地火明夷\n"); break;

case 122111:printf("\n天雷无妄\n"); break;

case 122112:printf("\n泽雷随\n"); break;

case 122121:printf("\n火雷噬嗑\n"); break;

case 122122:printf("\n震为雷\n"); break;

case 122211:printf("\n风雷益\n"); break;

case 122212:printf("\n水雷屯\n"); break;

case 122221:printf("\n山雷颐\n"); break;

case 122222:printf("\n地雷复\n"); break;

case 211111:printf("\n天风姤\n"); break;

case 211112:printf("\n泽风大过\n"); break;

case 211121:printf("\n火风鼎\n"); break;

case 211122:printf("\n雷风恒\n"); break;

case 211211:printf("\n巽为风\n"); break;

case 211212:printf("\n水风井\n"); break;

case 211221:printf("\n山风蛊\n"); break;

case 211222:printf("\n地风升\n"); break;

case 212111:printf("\n天水讼\n"); break;

case 212112:printf("\n泽水困\n"); break;

case 212121:printf("\n火水未济\n"); break;

case 212122:printf("\n雷水解\n"); break;

case 212211:printf("\n风水涣\n"); break;

case 212212:printf("\n坎为水\n"); break;

case 212221:printf("\n山水蒙\n"); break;

case 212222:printf("\n地水师\n"); break;

case 221111:printf("\n天山遁\n"); break;

case 221112:printf("\n泽山咸\n"); break;

case 221121:printf("\n火山旅\n"); break;

case 221122:printf("\n雷山小过\n"); break;

case 221211:printf("\n风山渐\n"); break;

case 221212:printf("\n水山蹇\n"); break;

case 221221:printf("\n艮为山\n"); break;

case 221222:printf("\n地山谦\n"); break;

case 222111:printf("\n天地否\n"); break;

case 222112:printf("\n泽地萃\n"); break;

case 222121:printf("\n火地晋\n"); break;

case 222122:printf("\n雷地豫\n"); break;

case 222211:printf("\n风地观\n"); break;

case 222212:printf("\n水地比\n"); break;

case 222221:printf("\n山地剥\n"); break;

case 222222:printf("\n坤为地\n"); break;

default:printf("\n错误\n"); break;

}

return 0;

}

算卦怎么能成为高手(业余自学编程第二十五天编写一个周易摇卦程序)(1)

自己摇了个雷山小过

猜您喜欢: