| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 743 人关注过本帖
标题:请教大家一个令我十分郁闷的编程题
取消只看楼主 加入收藏
kongyuehen
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-4-6
收藏
 问题点数:0 回复次数:3 
请教大家一个令我十分郁闷的编程题

题目:
第一题
It is really amazing that the great historian Dr.K has recently found that about 10 Million years ago, in the area where is now called China, lived an ancient people. They may be considered as the first intelligent creature existed on the earth.

As Dr.K's investigation advance, he found unbelievably that they even developed some so-called mathematics during their evolvement. Dr.K spent his half life to understand this ancient people's counting system. Finally he got to know that:
1、They use only 7 digits to represent numbers, and numbers are as follow:
| -> 1
|| -> 2
||| -> 3
|||| -> 4
||||| -> 5
|||||| -> 6
||||||| -> 7
It is a pity that they have not developed "0" before these people disappeared.
2、If a number is greater than 7, they use digit place just as we do today. Between each two digit places, there is a ",".
eg:
|||||,|| -> 42 (5x8+2)
|||,||,|||| -> 212 (3*64+2*8+4)

In order to further his study, Dr.K wants to know what the sequences found from stones mean in today's counting system. He turns to you for help, and smart as you are, you should help this great historian,should not you?

Input

The first line of standard input contains an integer N, the number of test cases. N lines followed.
In each line a sequence is given, it is guaranteed that the length of the sequence will not exceed 1024 characters and the outcome number will not be greater than 1000000.

Output

For each case you are to output a line giving the number in today's decimal counting system.

Sample Input

3
|||||,||
|||,||,||||
||,|,|,|,||||


Sample Output

42
212
8780

搜索更多相关主题的帖子: first understand developed recently 
2007-04-28 23:07
kongyuehen
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-4-6
收藏
得分:0 
简言之:
输入3
|||||,||
|||,||,||||
||,|,|,|,||||
输出:
42
212
8780
2007-04-28 23:08
kongyuehen
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-4-6
收藏
得分:0 

为什么这段程序在i=1时是正确的,而在i>1时是错误的
#include <stdio.h>
#define MAX 54
void main()
{
char p;
int i,j,x;
float m=0,k=0;
char str[1024][MAX];
scanf("%d",&i);
printf("\n");
for(j=1;j<=i;j++)
{
scanf("%s",str[j]);
p=str[j][0];
while(p!='\0')
{
while(p!=',')
{k++;m++;
p=str[j][m];
if(p=='\0') goto loop;
}
m++;
k=k*8;
p=str[j][m];
}
loop: printf("%f\n",k);
}
}

如输入 1
     ||||,||||
输出 36 正确
而输入 2       输出
    ||||    4
    |,||    5
 错误
令我很郁闷,哪位大侠帮帮忙啊!!!!!

2007-04-28 23:13
kongyuehen
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-4-6
收藏
得分:0 

谢谢!实在是昨天头脑短路了!!!!!!谢谢

2007-04-29 12:47
快速回复:请教大家一个令我十分郁闷的编程题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016230 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved