c程序基本算法百例之八—借书方案知多少
2011-05-15 16:06
323 查看
#include"stdio.h" int main() { int a,b,c,count=0; printf("借书方案为:/n"); for(a=1;a<=5;a++) for(b=1;b<=5;b++) for(c=1;a!=b&&c<=5;c++) if(c!=a&&c!=b) printf(count%5?"%2d:%d,%d,%d ":"%2d:%d,%d,%d/n",++count,a,b,c);// ?"":为若为真则实行前者,为假执行后者 return 0; } /* output: -------------------------------------------------------------------------------------- 借书方案为: 1:1,2,3 2:1,2,4 3:1,2,5 4:1,3,2 5:1,3,4 6:1,3,5 7:1,4,2 8:1,4,3 9:1,4,5 10:1,5,2 11:1,5,3 12:1,5,4 13:2,1,3 14:2,1,4 15:2,1,5 16:2,3,1 17:2,3,4 18:2,3,5 19:2,4,1 20:2,4,3 21:2,4,5 22:2,5,1 23:2,5,3 24:2,5,4 25:3,1,2 26:3,1,4 27:3,1,5 28:3,2,1 29:3,2,4 30:3,2,5 31:3,4,1 32:3,4,2 33:3,4,5 34:3,5,1 35:3,5,2 36:3,5,4 37:4,1,2 38:4,1,3 39:4,1,5 40:4,2,1 41:4,2,3 42:4,2,5 43:4,3,1 44:4,3,2 45:4,3,5 46:4,5,1 47:4,5,2 48:4,5,3 49:5,1,2 50:5,1,3 51:5,1,4 52:5,2,1 53:5,2,3 54:5,2,4 55:5,3,1 56:5,3,2 57:5,3,4 58:5,4,1 59:5,4,2 60:5,4,3 Process returned 0 (0x0) execution time : 0.312 s Press any key to continue. --------------------------------------------------------------------------------------- */
相关文章推荐
- c程序基本算法百例之三—绘制圆
- (百例编程)8.借书方案知多少
- c语言基本算法程序百例之十—数值转换
- c程序基本算法百例之七—阶层尾数零的个数
- c程序基本算法百例之一—绘制余弦曲线
- c程序基本算法百例之四—歌手大奖赛评分
- c程序基本算法百例之五—求最大公约数
- c语言基本算法程序百例之九—杨辉三角形
- 最简单的问题与算法(借书方案知多少)
- c程序基本算法百例之六—高次方数的尾数
- 借书方案值多少
- 试题:基本算法题之【n块钱最多可以喝多少瓶汽水】
- 试题:基本算法题之【计算买股票的第n天每股股票值多少钱】
- 借书方案多少
- 程序算法艺术与实践:递归策略基本的思想
- 1.2_借书方案知多少
- AIX 程序设计大赛-AIX正方形问题算法及Java程序实现(方案二)
- 一个应用二叉树基本算法的程序 zz
- 一个应用单链表基本算法的综合程序
- 借书方案知多少