24
来源:互联网 发布:淘宝产品摄影技巧 编辑:程序博客网 时间:2024/05/01 03:52
// game.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
float a[24][4];
char b[64][3];
void swap(float *a, float *b)
{
float m;
m = *a;
*a = *b;
*b = m;
}
void perm(float list[], int k, int m)
{
int i;
static int n=0;
if(k > m)
{
for(i = 0; i <= m; i++)
{
//printf("%d ", list[i]);
a[n][i] = list[i];
//printf("%f ", a[n][i]);
}
printf("\n");
n++;
}
else
{
for(i = k; i <= m; i++)
{
swap(&list[k], &list[i]);
perm(list, k + 1, m);
swap(&list[k], &list[i]);
}
}
}
int main(int argc, char* argv[])
{
int list[] = {0, 1, 2, 3};
float a1[4] = {2.0,4.0,5.0,6.0};
char d[2] = {'(',')'};
perm(a1, 0, 3);
//printf("total:%d\n", n);
// float a[4] = {2.0,4.0,5.0,6.0};
static int count =0;
char c[4] = {'+','-','*','/'};
for(int j=0;j<4;j++)
for(int k=0;k<4;k++)
for(int r=0;r<4;r++)
{
//printf("%f%c%f%c%f%c%f",a[list[1]],b[j],a[list[2]],b[k],a[list[3]],b[r],a[list[4]]);
//printf("%d\n",j*4*4+k*4+r);
b[j*4*4+k*4+r][0] = c[j];
b[j*4*4+k*4+r][1] = c[k];
b[j*4*4+k*4+r][2] = c[r];
//printf("%c%c%c\n",b[j*4*4+k*4+r][0],b[j*4*4+k*4+r][1],b[j*4*4+k*4+r][2]);
count++;
}
// printf("%d\n",count);
for(int i=0;i<24;i++)
for(int j=0;j<64;j++)
{
printf("%c%f%c%f%c%c%f%c%f\n",d[0],a[i][0],b[j][0],a[i][1],d[1],b[j][1],a[i][2],b[j][2],a[i][3]);
}
return 0;
}
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 24
- 2010.5.24-2012.5.24
- 2005.1.24
- 2005.2.24
- Range Minimum Query and Lowest Common Ancestor(RMQ和LCA 找个时间翻译下)
- 【转】解决“Microsoft Word已停止工作”的两个办法
- sys_init_module & sys_delete_module 简要分析
- 7.23引以为戒 马后炮不如加强系统监控
- 能人不一定是好领导
- 24
- XML
- 古代谜题——狼,羊,白菜,农夫过河问题
- REDHAT5.4下ORACLE10G安装注意事项
- 图片在div中的居中问题
- list control实现鼠标点击事件以及edit box实现只读
- 9.26随笔 XML
- HTML语言基本结构主体标记格式超级链接和列表
- 论坛恢复了,域名也恢复了,网站空间暂时还没开通