蛮力法
来源:互联网 发布:哆点校园mac版 编辑:程序博客网 时间:2024/05/21 12:03
#include <stdio.h>
#include <stdlib.h>
//200624101101杨振平
//2008年11月4日21:43编写
//the algorithm of the force method
void main()
{
//the defination of printing menu function
int menu();
//the defination of Algorithm of double method
void dbAlgorithm();
//the defination of Algorithm of int method
void intAlgorithm();
//inputs variable to choose menu's item
int quit=0;
while(!quit)
switch(menu())
{
case 1: dbAlgorithm();break;
case 2: intAlgorithm();break;
default: quit=1;
}
}
//print menu
int menu()
{
printf("|----------------------------------------|/n");
printf("|Please choose a menu: |/n");
printf("| 1 :Algorithm of double method |/n");
printf("| 2 :Algorithm of int method |/n");
printf("|Other keys:exit... |/n");
printf("|----------------------------------------|/n");
int ch;
scanf("%d",&ch);
return ch;
}
//the implement of double method algorithm
void dbAlgorithm()
{
double a,b,c,d,temp;
for(a=0.01;a<7.11;a=a+0.01)
for(b=0.01;b<7.11;b=b+0.01)
{
if(7.11-a-b>0)
for(c=0.01;c<7.11;c=c+0.01)
{
d=7.11-a-b-c;
if(d>0)
{
temp=a*b*c*d;
if(temp>7.109999 && temp<7.110001)
{
printf("a=%f,/tb=%f,/tc=%f,/td=%f,/t/n",a,b,c,d);
return ;
}
}
}
}
}
//the implement of int method algorithm
void intAlgorithm()
{
int a,b,c,d,temp;
for(a=1;a<711;a++)
for(b=1;b<711;b++)
{
if(711-a-b>0)
for(c=1;c<711;c++)
{
d=711-a-b-c;
if(d>0)
{
temp=a*b*c*d;
if(temp==711000000)
{
printf("a=%f,/tb=%f,/tc=%f,/td=%f,/t/n",(float)a/100,(float)b/100,(float)c/100,(float)d/100);
return ;
}
}
}
}
}
- 蛮力法
- 蛮力法
- 蛮力法
- 蛮力法
- 蛮力法习题
- Coin Change----------蛮力法
- 蛮力法(Brute Force)思想
- 蛮力法之01背包
- 基本算法之蛮力法
- 蛮力法背包问题
- 蛮力法最近对问题
- 蛮力法(一):穷举
- 排序1--冒泡(蛮力法)
- 排序2--选择(蛮力法)
- (三) 蛮力法
- 常见蛮力法排序
- 算法设计之蛮力法
- 蛮力法求解旅行商
- .NET 4.0 “Covariance”和“Contravariance”趣话
- System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本
- Silverlight 自定义控件的继承问题2
- MS-SQL2005服务器登录名、角色、数据库用户、角色、架构的关系
- 我把IT给哲学了
- 蛮力法
- 如何查询SQL2005的连接数
- 记单词
- 分治法
- ERP讲义11--项目管理中常见沟通问题及应对方法
- 合并排序
- ftp和系统时间相差8小时,vsftpd
- EHCache的一点介绍
- 快速排序