C语言 · 猜灯谜

标题:猜灯谜

A 村的元宵节灯会上有一迷题:

请猜谜 * 请猜谜 = 请边赏灯边猜

小明想,一定是每个汉字代表一个数字,不同的汉字代表不同的数字。

请你用计算机按小明的思路算一下,然后提交“请猜谜”三个字所代表的整数即可。

请严格按照格式,通过浏览器提交答案。
注意:只提交一个3位的整数,不要写其它附加内容,比如:说明性的文字。

 1 /*8 9 7*/
 2 #include<string.h>
 3 #include<stdio.h>
 4 bool use[10];//访问标记数组
 5 int a[10];
 6
 7 void dfs(int begin){
 8     if(begin==6){
 9         int yin1=a[0]*100+a[1]*10+a[2];
10         int yin2=a[0]*100+a[1]*10+a[2];
11         int yin3=a[0]*100000+a[3]*10000+a[4]*1000+a[5]*100+a[6]*10+a[1];
12         if(yin1*yin2==yin3){
13             printf("%d %d %d\n",a[0],a[1],a[2]);
14         }
15         return;
16     }
17     for(int i=0; i<=9; i++){
18         if(!use[i]){
19             use[i] = true;
20             a[begin]=i;
21             dfs(begin+1);
22             use[i] = false;
23         }
24     }
25 }
26 int main(){
27     memset(use,false,sizeof(use));
28     dfs(0);
29     return 0;
30 }
时间: 2024-08-10 21:30:12

C语言 · 猜灯谜的相关文章

jQuery元宵猜灯谜特效(元宵十五日猜一个字)

在线体验:http://keleyi.com/keleyi/phtml/jqtexiao/35.htm jQuery元宵猜灯谜特效的HTML代码如下: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>元宵十五日猜一个字 - 可乐义</title> <meta name="description" con

ytu2572——猜灯谜

题目描写叙述 A 村的元宵节灯会上有一迷题: 请猜谜 * 请猜谜 = 请边赏灯边猜 小明想,一定是每一个汉字代表一个数字,不同的汉字代表不同的数字. 请你帮小明把全部的可能的数都找出来吧. 输入 没有输入 输出 提交请猜谜所代表的3位的整数. 代码 #include<iostream> using namespace std; int main() { int a,b,c,y; for(int x=100;x<1000;x++) { if(x*x>=100000) { y=x*x;

C语言 猜数字游戏

#include <stdio.h> #include <stdlib.h> #include <time.h> void guess() {  int input = 0;  int ret;  srand((unsigned int)time(NULL));  ret = rand() % 100;  printf("请输入0-100内的数字\n");  do  {   scanf("%d",&input);   if

C语言 &#183; 猜算式

题目:猜算式 看下面的算式: □□ x □□ = □□ x □□□ 它表示:两个两位数相乘等于一个两位数乘以一个三位数. 如果没有限定条件,这样的例子很多. 但目前的限定是:这9个方块,表示1~9的9个数字,不包含0. 该算式中1至9的每个数字出现且只出现一次! 比如: 46 x 79 = 23 x 158 54 x 69 = 27 x 138 54 x 93 = 27 x 186 ..... 请编程,输出所有可能的情况! 注意:左边的两个乘数交换算同一方案,不要重复输出! 要求考生把所有函数写

C语言猜数字小游戏

#include <stdio.h> #include <time.h> #include <stdlib.h> int main() { int x,num,st,ed; char ch; srand((int)time(NULL)); while(1) { printf("请输入你想要猜的数的范围(用空格隔开):"); scanf("%d %d",&st,&ed); ed=ed-st+1; num=rand()

一些项目——猜灯谜

题目描述 A 村的元宵节灯会上有一迷题: 请猜谜 * 请猜谜 = 请边赏灯边猜 小明想,一定是每个汉字代表一个数字,不同的汉字代表不同的数字. 请你帮小明把所有的可能的数都找出来吧. 输入 没有输入 输出 提交请猜谜所代表的3位的整数. 代码 #include<iostream> using namespace std; int main() { int a,b,c,y; for(int x=100;x<1000;x++) { if(x*x>=100000) { y=x*x; a=

C语言 猜数游戏--产生一个随机数

#include <stdio.h> #include <time.h> #include <stdlib.h> int main(int argc, const char * argv[]) { // insert code here... printf("Hello, World!\n"); int a,b,i; { srand((unsigned int)time(0)); b = rand()%100 + 1; // printf("

c语言-猜生日算法

#include<stdio.h>int main(){ int a1[6]={1,3,5,7,9,11}; int a2[6]={2,3,6,7,10,11}; int a3[6]={4,5,6,7,12,0}; int a4[6]={8,9,10,11,12,0}; int b1[4][4]={{1,3,5,7},{9,11,13,15},{17,19,21,23},{25,27,29,31}}; int b2[4][4]={{2,3,6,7},{10,11,14,15},{18,19,2

算法笔记_203:第四届蓝桥杯软件类决赛真题(C语言B组)

目录 1 猜灯谜 2 连续奇数和 3 空白格式化 4 高僧斗法 5 格子刷油漆 6 农场阳光   前言:以下代码仅供参考,若有错误欢迎指正哦~ 1 猜灯谜 标题:猜灯谜 A 村的元宵节灯会上有一迷题: 请猜谜 * 请猜谜 = 请边赏灯边猜 小明想,一定是每个汉字代表一个数字,不同的汉字代表不同的数字. 请你用计算机按小明的思路算一下,然后提交"请猜谜"三个字所代表的整数即可. 请严格按照格式,通过浏览器提交答案. 注意:只提交一个3位的整数,不要写其它附加内容,比如:说明性的文字. 9