ZOJ 1334 Basically Speaking

实例讲解MOS管电源开关电路的软启动 1、控制电源开关的输入信号 Control 为低电平或高阻时,三极管Q2的基极被拉低到地,为低电平,Q2不导通,进而MOS管Q1的Vgs = 0,MOS管Q1不导通,+5V_OUT 无输出。此时将 Control 设为低电平,三极管Q2关闭,电容C1与G极相连端通过电阻R2放电,电压逐渐上升到5V,起到软关闭的效果。不过从作者的描述来看,只是电路参数有区别,能通过的电流、能承受的耐压等不一样,但是软启动的原理是一样的。从公式可以看出,当电容容量越大,电压越高,时间越短,电流就会越大,从而形成浪涌电流。 阅读详情
Basically Speaking

Time Limit: 2 Seconds      Memory Limit: 65536 KB

The Really Neato Calculator Company, Inc. has recently hired your team to help design their Super Neato Model I calculator. As a computer scientist you suggested to the company that it would be neato if this new calculator could convert among number bases. The company thought this was a stupendous idea and has asked your team to come up with the prototype program for doing base conversion. The project manager of the Super Neato Model I calculator has informed you that the calculator will have the following neato features:

It will have a 7-digit display.

Its buttons will include the capital letters A through F in addition to the digits 0 through 9.

It will support bases 2 through 16.


Input

The input for your prototype program will consist of one base conversion per line. There will be three numbers per line. The first number will be the number in the base you are converting from. The second number is the base you are converting from. The third number is the base you are converting to. There will be one or more blanks surrounding (on either side of) the numbers. There are several lines of input and your program should continue to read until the end of file is reached.


Output

The output will only be the converted number as it would appear on the display of the calculator. The number should be right justified in the 7-digit display. If the number is to large to appear on the display, then print ``ERROR'' (without the quotes) right justified in the display.

Sample Input

1111000 2 10 1111000 2 16 2102101 3 10 2102101 3 15 12312 4 2 1A 15 2 1234567 10 16 ABCD 16 15

Sample Output

    120
     78
   1765
    7CA
  ERROR
  11001
 12D687
   D071
题意:进制的转换
注意:还有用scanf(%s)时,空格不会被读进来
代码:
#include <stdio.h>
#include <string.h>
int main()
{
    char str[30];
    int b1,b2;
    int inta[71];
    int len;
    int i,j;
    inta['0']=0;
    inta['1']=1;
    inta['2']=2;
    inta['3']=3;
    inta['4']=4;
    inta['5']=5;
    inta['6']=6;
    inta['7']=7;
    inta['8']=8;
    inta['9']=9;
    inta['A']=10;
    inta['B']=11;
    inta['C']=12;
    inta['D']=13;
    inta['E']=14;
    inta['F']=15;
    while(scanf("%s %d %d",str,&b1,&b2)!=EOF) {
        len=strlen(str);
        int k=1;
        int sum=0;
        int m;
        i=len-1;
        while(i>=0)
        {
            sum+=inta[str[i]]*k;
            k=k*b1;
            i--;
        }
        i=0;
        while(sum>0)
        {
            int temp=sum%b2;
            if(temp>=10)
                str[i++]=(char)(temp-10+'A');
            else
                str[i++]=(char)(temp+'0');
            sum/=b2;
        }
        if(i>7)
        {
            printf("  ERROR\n");
        }
else
        {
for(m=0;m<7-i;m++)
                printf(" ");
            for(j=i-1;j>=0;j--)
                printf("%c",str[j]);
            printf("\n");
}
    }
    return 0;
}
C#面试题及详细答案120道(01-10)-- 基础语法与数据类型 C#与.NET部分重点解析了7个核心问题:1)C#与.NET的依存关系;2)值类型与引用类型的内存差异;3)装箱拆箱的性能损耗;4)string/String与int/Int32的实质等价性;5)const与readonly的初始化区别;6)可空类型的应用场景;7)ref与out关键字的参数传递机制。内容包含原理对比、代码示例和优化建议,适合开发者系统掌握C#核心概念。(1 阅读详情

相关推荐

通过Robotstudio修改机器人程序的具体方法和步骤

通过Robotstudio修改机器人程序的具体方法和步骤

Robot_PLC_HMI_Automation 6351

1334_Basically Speaking

The Really Neato Calculator Company, Inc. has recently hired your team to help design their Super Neato Model I calculator. As a computer scientist you suggested to the company that it would be neato

李松雨的专栏 354

基于Simulink的四足机器人关节力矩优化仿真建模示例

高自由度:每个腿至少有3个自由度(DOF),增加了控制的复杂性。非线性动力学:涉及多体系统的相互作用,包括接触力、摩擦力等。能量消耗:减少不必要的能量消耗是提升续航能力和效率的关键。可以是最小化能量消耗或最大化稳定性等。matlab深色版本% 示例代码通过本指南,我们介绍了如何基于Simulink搭建一个四足机器人的关节力矩优化模型,并进行了仿真以验证其基本功能。

amy_mhd的博客 153

zoj1334Basically Speaking

ZOJ Problem Set - 1334 Basically Speaking Time Limit: 2 Seconds      Memory Limit: 65536 KB The Really Neato Calculator Company, Inc. has recently hired your team to help design their Super Neato M

lonely_Quan的专栏 542

zoj 1334 Basically Speaking

#include "iostream" #include "map" #include "string" #include "cmath" #include "algorithm" #include "iomanip" using namespace std; int main() { string str, ans; int b1, b2, i, j, len1, len2, num;

yzl_rex 614

zoj 1334 Basically Speaking

#include "iostream" #include "map" #include "string" #include "cmath" #include "algorithm" #include "iomanip" using namespace std; int main() { string str, ans; int b1, b2, i, j, len1, len2, num;

yzl_rex 391

HDU 1335 || ZOJ 1334 Basically Speaking

#include #define MAX 0x7FFFFFFF int x,sum,len,m,n,i,j; int a[100]; char s[100]; void TenTo(char* s, int sum,int n) { i=0; while(sum) { a[i]=sum%n; sum/=n;

恋&空的专栏 782

zoj 1334 Basically Speaking(进制转换)

如果你知道FFFFFFF的十进制数是268435455,并且int的范围是2147483647的话,此题可以直接水过。我初始看到此题还是懵了下怕转换的中间值十进制会超过范围...多虑了。 学弟问的,代码基本上没变 #include #include int main() { char s[150],t[8]; int i,a,b,su,j,d,l,r,w; while(scanf("%s

uiiの技术随笔 1079

HDU1335 POJ1546 UVA389 UVALive5306 ZOJ1334 Basically Speaking

Basically Speaking Time Limit:1000MS Memory Limit:10000K Total Submissions:4772 Accepted:2141 Description The Really Neato Calculator Company, Inc. has recently h...

weixin_34396902的博客 82

ZOJ 2172 Symmetric Order

Symmetric Order Time Limit: 2 Seconds      Memory Limit: 65536 KB In your job at Albatross Circus Management (yes, it's run by a bunch of clowns), you have just finished writing a program whose

胖子加油! 1743

ZOJ 1113 u Calculate e

u Calculate e Time Limit: 2 Seconds      Memory Limit: 65536 KB Background A simple mathematical formula for e is where n is allowed to go to infinity. This can actually yield very acc

胖子加油! 1300

ZOJ 1001 A + B Problem

A + B Problem Time Limit: 2 Seconds      Memory Limit: 65536 KB Calculate a + b Input The input will consist of a series of pairs of integers a and b,separated by a space, one pair of inte

胖子加油! 1211

ZOJ 1073 Round and Round We Go

Round and Round We Go Time Limit: 2 Seconds      Memory Limit: 65536 KB Problem A cyclic number is an integer n digits in length which, when multiplied by any integer from 1 to n, yields a ��

胖子加油! 1128

ZOJ 1382 A Simple Task

A Simple Task Time Limit: 2 Seconds      Memory Limit: 65536 KB Given a positive integer n and the odd integer o and the nonnegative integer p such that n = o2^p. Example For n = 24, o = 3

胖子加油! 793

ZOJ 1110 Dick and Jane

Dick and Jane Time Limit: 2 Seconds      Memory Limit: 65536 KB Dick is 12 years old. When we say this, we mean that it is at least twelve and not yet thirteen years since Dick was born. Dick a

胖子加油! 734

ZOJ 1813 Biker's Trip Odometer

Biker's Trip Odometer Time Limit: 2 Seconds      Memory Limit: 65536 KB Most bicycle speedometers work by using a Hall Effect sensor fastened to the front fork of the bicycle. A magnet is attach

胖子加油! 722

ZOJ 2108 Elevator

Elevator Time Limit: 2 Seconds      Memory Limit: 65536 KB The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which

胖子加油! 659

ZOJ 1871 Steps

Steps Time Limit: 2 Seconds      Memory Limit: 65536 KB One steps through integer points of the straight line. The length of a step must be nonnegative and can be by one bigger than, equal to, o

胖子加油! 654

gp88gp300中文写频

支持win7 32位 64位系统 本软件在XP、WIN7、WIN10等32位系统下均测试正常64位系统暂时未经测试部份系统因为权限关系,如WIN10请右击以管理员身份运行如不能正常工作可联系

Mac_VMwareFusion虚拟机.zip

Mac_VMwareFusion虚拟机,v8.0.2,安装可用。

上一篇: ZOJ 1331 Perfect Cubes
下一篇: ZOJ 1337 Pi
wpfengqi
博客等级 码龄14年 6粉丝 121原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值