当前位置:网站首页>1149: 组合三位数之二
1149: 组合三位数之二
2022-04-21 09:06:00 【谦QIAN】
1149: 组合三位数之二
题目描述
把1,2,3,4,5,6,7,8,9,组成三个三位数(每个数只能用一次),第二个数是第一个数的2倍,第三个数是第一个数的3倍,这三个三位数各是多少?答案可能有很多组,请按第一个数的升序顺序输出每组的三个三位数。
输入
无
输出
输出所有满足条件的三位数组合,按第一个数的升序顺序输出。
样例输出 Copy
192 384 576
…
来源/分类
#include<stdio.h>
#include<string.h>
/* 第一个数不重复(123——329) 2倍,三倍也不重复且不能出现0 三个数再比较是否重复 */
//判断这个三位数是否有重复的数字,没有重复返回1,个位十位不为0
int doub(a){
if((a%10!=a/100)&&(a/100!=a/10%10)&&(a%10!=a/10%10)&&a%10!=0&&a/10%10!=0) return 1;
return 0;
}
//判断两个三位数是否有重复的数字,没有重复返回1
int Isrepeat(a,b){
if(b%10==a%10||b%10==a/10%10||b%10==a/100) return 0;
if(b/10%10==a%10||b/10%10==a/10%10||b/10%10==a/100) return 0;
if(b/100==a%10||b/100==a/10%10||b/100==a/100) return 0;
return 1;
}
int main(){
int a[50];
for(int i=123;i<330;i++){
//三个数各自没有重复的数字
if(doub(i)&&doub(2*i)&&doub(3*i)) {
//三个数都没有重复的数字
if(Isrepeat(i,2*i)&&Isrepeat(2*i,3*i)&&Isrepeat(i,3*i)){
printf("%d %d %d\n",i,2*i,3*i);
}
}
}
return 0;
}
版权声明
本文为[谦QIAN]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_44500344/article/details/107833667
边栏推荐
- Handler asynchronous message passing mechanism (I) common basic usage of handler
- 【Appium】使用模拟器实现有道云App的业务功能-新增、搜索、修改、删除
- ACTF2020 新生赛 Upload 1
- PC微信機器人個人號接口api之實戰分析微信同意好友call
- 2022年流动式起重机司机考试练习题模拟考试平台操作
- 【CVPR 2020】PointASNL :Robust Point Clouds Processing using Nonlocal Neural Networks
- [MySQL] Based on linux-centos7 9 detailed installation tutorial
- Flink的api入门案例
- Garbage collection mechanism
- Handler异步消息传递机制(一)Handler常用基本用法
猜你喜欢

CC00026.CloudJenkins—————————————

Meizu, once expected to challenge apple, now lives by providing accessories for Apple users

Ue5 little knowledge point animation blueprint interface cannot copy new in editor

Pipy MQTT 代理之(三)Logging

Binary tree knowledge

Netease blog is going to be closed. My article!

2022年上海市安全员C证考试模拟100题及模拟考试

Getting started with object detection FAQs (deep learning / image classification)

PageRank case Airport

pyinstaller打包exe(详细教程)
随机推荐
pyinstaller打包exe(详细教程)
Detailed explanation of kotlin cooperation process lanch
idea连接SqlServer报错
2022 mobile crane driver examination exercises simulated examination platform operation
渗透测试-获取系统FOFA关键字来刷洞
原生与H5混合式开发详解
【Appium】使用模拟器实现有道云App的业务功能-新增、搜索、修改、删除
BUUCTF[HCTF 2018]WarmUp
C#100分秘籍 sduwh
The database has a table in which JSON data is stored in one field. I need to parse this string when this table is updated, and then update the parsed JSON data to another table. What are the good sug
[(strongly pushed) Li Hongyi 2021 / 2022 spring machine learning course] unsupervised learning - linear methods
CC00019.CloudJenkins—————————————
A system has n processes with a total of 7 resources. Each process needs 3 resources. What is the maximum number of N without deadlock? (analysis attached)
Handler asynchronous message passing mechanism (I) common basic usage of handler
Worker man passes parameters to the method in timer
2022年T电梯修理考题及在线模拟考试
Penetration practice - no echo rce thinkphp5 getshell
L2-031 深入虎穴 (25 分)
[appium] use the simulator to realize the business functions of Youdao cloud app - add, search, modify and delete
C 100 points secret script sduwh