这类东西,无非就是穷举法。见下面代码:

#include <stdio.h>
#include <stdlib.h> /*
*abc + cba = 1333
*
*a = ?
*b = ?
*c = ?
*/ int main(int argc ,char **argv)
{
int a=;
int b=;
int c=; int index = ; printf("abc + cba == 1333\n"); for(a = ; a <= ; a++)//a [1,9]
{
for(b = ; b <= ; b++)//b [0,9]
{
for(c = ; c <= ; c++)//c [1,9]
{
if( == (*a + *b + c + *c + *b + a))
{
index++;
printf("I have found it !!! index : %d , a= %d, b= %d, c=%d\n",index,a,b,c);//多谢1楼仁兄,找到了,却没有注意英文语法,已改found及I }
}
}
} printf("find over\n");
return ;
}

运行结果;

tiger@ubuntu:/mnt/hgfs/e/Lessons/MyExercise/UtilLibs/EXERCISE$ ./abc
abc + cba == 1333
I have found it !!! index : 1 , a= 4, b= 1, c=9
I have found it !!! index : 2 , a= 5, b= 1, c=8
I have found it !!! index : 3 , a= 6, b= 1, c=7
I have found it !!! index : 4 , a= 7, b= 1, c=6
I have found it !!! index : 5 , a= 8, b= 1, c=5
I have found it !!! index : 6 , a= 9, b= 1, c=4
find over
tiger@ubuntu:/mnt/hgfs/e/Lessons/MyExercise/UtilLibs/EXERCISE$

最新文章

  1. Solr5 DataImport 处理1对多关系
  2. 【转】敏捷开发 Scrum 总结
  3. jquery仿天猫商城左侧导航菜单
  4. HttpClient使用笔记
  5. cf442C Artem and Array
  6. MySQL学习笔记(2)
  7. Hdu 5256 系列转换
  8. windows下使用git管理github项目
  9. Linux文件属性上
  10. ubuntu安装pycharm桌面快捷方式
  11. java quartz 计算近20次执行时间
  12. [转]快速新建简单的koa2后端服务
  13. 关于Java方法重载
  14. linux 下导出oracle数据库
  15. 【杂谈】Tomcat 之 Lifecycle接口
  16. centos7环境安装ElasticSearch
  17. Win7下VB6.0不能加载mscomctl.ocx的解决办法
  18. (原创)结构体自动化转为char数组的实现
  19. MacBook常用软件
  20. 解题:洛谷4314 CPU监控

热门文章

  1. POJ 2689
  2. hdfs工作原理
  3. 通知(NSNotification)
  4. HDU 3342 Legal or Not (图是否有环)
  5. 原型设计工具Axure 建模工具powerdesigner
  6. 关闭iptables(Centos)
  7. REDHAT YUM使用网易源
  8. Java核心技术II读书笔记(二)
  9. webpack的学习
  10. 一个强大的LogParser的UI工具--logparserlizard简介