fjnu 1946 Base Comparator

Description

DigiCircuits Inc. is a software company that develops software simulators for digital circuits. A very frequently used component of its software, named the comparator, is a simulated circuit that compares numbers expressed in different numerical bases. More exactly, this component receives two numbers, each one in a possible different base, and decides if the first number is less than, equal to or greater than the second number.
The numerical bases that may appear vary from 1 to 9. Remember that a number expressed in base b uses only digits less than b.

Your task is to develop a program that simulates the function of the comparator component.

Input

The input contains several test cases, each one of them in a separate line. Each test case has four numerical strings, each two of them separated by a blank character, say


s b t c

Strings b and c are one-character strings. They represent the bases for the first and third strings s and t, respectively.

The end of the input is denoted by the end of file.

Output

Output text for each input case is presented in the same order that input is read. For each test case the answer must be a left aligned answer-character corresponding to the input. This character must be < , = or > , accordingly to the fact that the first string represents a numerical value less than, equal to or greater that the represented by the third string.

Sample Input

54 6 71 8
110 2 6 7
3 4 3 9
14 7 1000 2

Sample Output

<
=
=
>

 

KEY:这个题我的思路是把两个数转化到相同进制里面(比如10进制),然后比较,问题在于他的输入的数比较大要用字符串存放,所得的数也较大,用用unsigned long存放;

 

Source:

#include
< iostream.h >
#include
< math.h >
#include
< string .h >
// using namespace std;

unsigned 
long  translate( char  str[], int   base )
{
    
int len=strlen(str);
    unsigned 
long sum=0;
    
int i,k;
    
for(i=len-1,k=0;i>=0;i--,k++)
    
{
        
int t=str[i]-'0';
        sum
+=t*(unsigned long)pow(base,k);
    }

    
return sum;
}


int  main()
{
//    freopen("fjnu_1946.in","r",stdin);
    char a1[1000],a2[1000];
    
int b1,b2;
    unsigned 
long t1,t2;
    
while(cin>>a1>>b1>>a2>>b2)
    
{
        t1
=translate(a1,b1);
        t2
=translate(a2,b2);
        
if(t1==t2) cout<<"="<<endl;
        
if(t1>t2) cout<<">"<<endl;
        
if(t1<t2) cout<<"<"<<endl;
    }

    
return 0;
}





 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好,以下是一个简单的使用HTML制作类似于"https://www.fjnu.edu.cn/main.htm"网页的示例代码: ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>福建师范大学</title> </head> <body> <header> <h1>福建师范大学</h1> </header> <nav> <ul> <li><a href="#">首页</a></li> <li><a href="#">学校概况</a></li> <li><a href="#">新闻中心</a></li> <li><a href="#">招生就业</a></li> <li><a href="#">校园生活</a></li> <li><a href="#">教学科研</a></li> <li><a href="#">校友服务</a></li> </ul> </nav> <main> <article> <h2>学校简介</h2> <p>福建师范大学创建于1907年,是福建省人民政府与教育部共建高校。学校主要办学特色是师范教育和人文社会科学,具有百年办学历史和深厚的文化底蕴。</p> </article> <section> <h2>新闻动态</h2> <ul> <li><a href="#">福建师范大学2021年迎新工作启动</a></li> <li><a href="#">2021年福建师范大学教师招聘公告</a></li> <li><a href="#">福建师范大学2021年本科招生计划</a></li> </ul> </section> </main> <aside> <h2>联系我们</h2> <p>地址:福建省福州市闽侯县上街镇</p> <p>电话:0591-83442777</p> <p>邮箱:fjnu@fjnu.edu.cn</p> </aside> <footer> <p>© 2021 福建师范大学</p> </footer> </body> </html> ``` 在这个示例中,我们使用HTML5标记语言来创建网页。我们通过`<header>`元素来定义网页的标题,通过`<nav>`元素来定义网页的主要导航,通过`<main>`元素来定义网页的主要内容,通过`<aside>`元素来定义网页的侧边栏内容,通过`<footer>`元素来定义网页的页脚。在`<main>`元素中,我们使用`<article>`元素来定义学校简介部分的内容,使用`<section>`元素来定义新闻动态部分的内容。网页的样式和布局可以通过CSS来实现。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值