NYOJ524A-B Problem

A-B Problem

时间限制:1000 ms  |  内存限制:65535 KB
难度:3
 
描述

A+B问题早已经被大家所熟知了,是不是很无聊呢?现在大家来做一下A-B吧。

现在有两个实数A和B,聪明的你,能不能判断出A-B的值是否等于0呢?

 
输入
有多组测试数据。每组数据包括两行,分别代表A和B。
它们的位数小于100,且每个数字前中可能包含+,- 号。
每个数字前面和后面都可能有多余的0。
每组测试数据后有一空行。
输出
对于每组数据,输出一行。
如果A-B=0,输出YES,否则输出NO。
样例输入
1
1

1.0
2.0
样例输出
YES
NO
View Code
 1  
 2 #include<stdio.h>
 3 #include<string.h>
 4  char stra[102],strb[102];
 5  int havepoint (char *str)
 6  {
 7      int i;
 8      int len=strlen(str);
 9      for(i=0;i<len;i++)
10      {
11        if(str[i]=='.')return 1;
12      }
13      return 0;
14  }
15 void change(char *str)
16  {
17       int len,i;
18       if(havepoint(str))
19       {
20          len=strlen(str);
21          for(i=len-1;i>=0;i--)
22             {
23               if(str[i]=='0')str[i]='\0';
24               else break;
25             }
26          len=strlen(str);
27          if(str[len-1]=='.')str[len-1]='\0';
28       }
29       if(str[0]=='+')
30       {
31            len=strlen(str);
32            int count=1;
33            for(i=1;i<len;i++)
34            {
35               if(str[i]=='0'&&str[i+1]!='\0')  count++;
36               else break;
37            }
38            for(i=0;i<len-count;i++)
39            {
40               str[i]=str[i+count];
41            }
42            str[i]='\0';
43       }
44       else if(str[0]=='-')
45       {
46            len=strlen(str);
47            int count=0;
48            for(i=1;i<len;i++)
49            {
50               if(str[i]=='0'&&str[i+1]!='\0')  count++;
51               else break;
52            }
53            for(i=1;i<len-count;i++)
54            {
55               str[i]=str[i+count];
56            }
57            str[i]='\0';
58            if(str[0]=='-'&&str[1]=='0'){str[0]='0';str[1]='\0';}
59       }
60       else 
61           {    
62                 len=strlen(str);
63                int count=0;
64                for(i=0;i<len;i++)
65                {
66                   if(str[i]=='0'&&str[i+1]!='\0')  count++;
67                   else break;
68                }
69                for(i=0;i<len-count;i++)
70                {
71                   str[i]=str[i+count];
72                }
73                str[i]='\0';
74       }
75       
76       
77    // puts(str);       
78  }
79          
80 int main()
81 {
82    
83     while(scanf("%s%s",&stra,&strb)!=EOF)
84     {
85         change(stra);change(strb);
86         printf("%s\n\n",strcmp(stra,strb)==0?"YES":"NO");
87     }
88     return 0;
89 }
90     
91     
92         

 

problem????

12-06

Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e14' rn[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '='. rnrn/EBusiness/visit/viewbasket.asp,行211 rnSet Rs=DataCon.Execute(SQLQuery)rnrn------------------------------------rn-------------------------------------rn<%rnSQLQuery="Select * From GoodsBasket Where User_ID="&User_IDrn'SQLQuery="Select * From Goods,GoodsBasket Where GoodsBasket.User_ID="&UserID&" And Goods.ID=GoodsBasket.Goods_ID"rnSet Rs=DataCon.Execute(SQLQuery)rni=0:nCost=0rnWhile Not Rs.EOFrn SQLQuery="Select * From Goods Where ID="&Rs("Goods_ID")rn Set RsGoods=DataCon.Execute(SQLQuery)rn%>rn------------------------rn问题为:Set Rs=DataCon.Execute(SQLQuery)语法错在那边?谢谢高手rn这是goods表CREATE TABLE [dbo].[GOODS] (rn [ID] [int] NOT NULL ,rn [Goods_Name] [varchar] (50) NOT NULL ,rn [Goods_Price] [real] NOT NULL ,rn [Goods_Amount] [int] NOT NULL ,rn [Goods_Unit] [varchar] (10) NOT NULL ,rn [Goods_Type_ID] [varchar] (50)NOT NULL ,rn [Goods_SubType_ID] [varchar](50) NOT NULL ,rn [Goods_Description] [varchar] (300) NOT NULL ,rn [Goods_Image] [image] NOT NULL ,rn [Goods_Image_Path] [varchar] (50) NOT NULL ,rn [Goods_Time] [datetime] NOT NULL ,rn [Goods_Hit] [int] NOT NULL ,rn [Goods_Sold] [int] NOT NULL rn) ON [PRIMARY]rnGOrngoodsbasket表rnCREATE TABLE [dbo].[GOODSBASKET] (rn [ID] [int] NOT NULL ,rn [GOODS_ID] [varchar](20) NOT NULL ,rn [USER_ID] [varchar] (20)NOT NULL ,rn [REQUEST_AMOUNT] [varchar](50) NOT NULL ,rn [REQUEST_DECRIPTION] [varchar] (200) NOT NULL ,rn [REQUESR_TIME] [datetime] NULL ,rn [SEND_TIME] [datetime] NOT NULL ,rn [SEND_METHOD] [varchar] (50) NOT NULL ,rn [ASSURANCE] [varchar](10) NULL rn) ON [PRIMARY]rnGOrn 论坛

EJB3 problem

04-13

Hi,rnrnI am new to EJBs and wanted to try the EJB3 Tutorial when some problems occuredrn. I think I must have done something wrong at the configuration of the JBossrnServer or at the deployment.rnrnI always get the following Errors:rnrn23:25:10,930 INFO [DLQ] Bound to JNDI name: queue/DLQrn23:25:13,233 INFO [ConnectionFactoryBindingService] Bound connection factoryrnfor resource adapter for ConnectionManager 'jboss.jca:servicern=ConnectionFactoryBinding,name=JmsXA to JNDI name 'java:JmsXA'rn23:25:14,335 INFO [Ejb3Module] found EJB3 stateless session bean: org.jbossrn.tutorial.stateless.bean.CalculatorBeanrn23:25:14,365 ERROR [Ejb3Module] Initialization failed jboss.j2ee:service=EJB3rn,module=e1.ejb3rnjava.lang.RuntimeException: Domain Stateless Bean not foundrn at org.jboss.ejb3.Ejb3Module.createService(Ejb3Module.java:128)rn at org.jboss.system.ServiceMBeanSupport.jbossInternalCreatern(ServiceMBeanSupport.java:238)rn at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecyclern(ServiceMBeanSupport.java:220)rn at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invokern(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:585)rn at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcherrn.java:144)rn at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)rn at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)rn at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.javarn:249)rnrn-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------rn----rnrn23:25:14,385 INFO [EJB3Deployer] Deployed: file:/C:/developement/Enviromentrn/jboss-4.0.1sp1/server/all/deploy/e1.ejb3rn23:25:15,056 INFO [Ejb3Module] found EJB3 service bean: org.jboss.tutorialrn.service.bean.ServiceOnern23:25:15,056 ERROR [Ejb3Module] Initialization failed jboss.j2ee:service=EJB3rn,module=eservice.ejb3rnjava.lang.RuntimeException: No container configured with name 'Service Bean''rn at org.jboss.ejb3.Ejb3Module.createService(Ejb3Module.java:175)rn at org.jboss.system.ServiceMBeanSupport.jbossInternalCreatern(ServiceMBeanSupport.java:238)rn at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecyclern(ServiceMBeanSupport.java:220)rn at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invokern(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:585)rn at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcherrn.java:144)rn at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)rnrnI hope you can help me.rnrnThank you very much in advance. 论坛

The problem is choice.

08-30

很多问题,没有对错可言,只在于看问题的立场不同而已。rnrn比如回答csdn的问题,一个简单的变量定义在循环内好还是循环外好的问题,怎么才知道那样好?写个代码测一下,一个profile结果很能说明问题,开IDE,写代码,做profile,十几分钟进去了,获得什么?rnrn十几分钟当然算不了什么,问题是,如果有人问,怎么java操作Excel?如果写个详细的代码例子,恐怕就不是十几分钟可以搞定的了,回答一句“POI”?还是不回答?抑或只是一个“顶”?如果提问者非要一个详细的例子,我恐怕连“顶”的愿望都没有——没心情做这种费力不讨好的事情——我早过了那种青春期精力过剩的年龄,工作、学习、家庭,有足够多的事情让我操心,犯不上。rnrn我想,所有的提问者,往往都希望尽可能详细的解答——甚至很多人希望不劳而获,没啥不好意思的,到处都是这个题怎么做,那个题怎么做的问题。不过,如果仅仅作为希望,那没啥错误,但是把希望提高到道德水准,提高到,如果回答问题的人不做的尽善尽美,就是误导,就是缺德,那,恐怕是过分了。rnrn帮,是情分,不帮,是本分,这,恐怕没工作经验的人,是不会理解的。扯远一点,这也是我招人的原则——没工作经验的一律不要——哪怕这工作经验和我当前工作没任何关系,哪怕仅仅是麦当劳打工的经验,都好过完全没经验的人。rnrn客观是瞎扯,主观才是本质。想让csdn变得更有用,更多的人乐于来回答问题,来帮助别人,那么就不要对回答问题的人,对帮助别人的人,过于苛求。走在路上,累了,讨口水喝,也许人家会请你一起便饭;如果直接要求什么山珍海味的,估计除了白眼和口水,也就得不到更多的东西了。rnrnrnrnrn 论坛

Problem Bee

10-31

DescriptionnnImagine a perfectly formed honeycomb, spanning the infinite Cartesian plane. It is an interlocking grid composed of congruent equilateral hexagons. One hexagon is located so that its center is at the origin and has two corners on the X-axis. A bee must be very careful about how it travels in order not to get lost in the infinite plane. To get from an arbitrary point A to another arbitrary point B, it will first head from A to the exact center of the hexagon in which A is located. Then, it will travel in a straight line to the exact center of an adjacent hexagon. It will move from center to adjacent center until it has reached the hexagon containing point B. At the destination hexagon, it will move from the center to point B. In all cases the bee will take a path of minimal distance that obeys the rules. The figure below demonstrates one possible minimal path from point A to point B. nnInputnnInput will be in the form of 5 floating point numbers per line. The first number will be the length, in centimeters, of the sides of the hexagons. The next two numbers will be the x and y coordinates of point A, followed by the x and y coordinates for point B. The input will be terminated by a line containing five zeroes. Neither point A nor point B will ever be exactly on a border between hexagons.nOutputnnFor each line of the input, output the minimum length of a path from point A to point B, in centimeters, to the nearest .001 centimeters.nSample Inputnn1.0 -3.2 2.2 3.3 0n9 1 4 5 1n0.1 .09 0 .21 0n0 0 0 0 0nSample Outputnn7.737n5.000n0.526 问答

ShaDan’ Problem

06-21

Problem DescriptionnLong long ago , there is a person named ShaDan. He likes walking around the streets very much. He walks around the street until the sky is black every day. When he go back home , his mother always very angry with him. “what are you doing , it’ s so late now” his mother always asked him loudly. ShaDan always answer “I’m watching the scenery around the street”.nOne day, when ShaDan was walking around the street, he thought how can I visit all the streets and cost minimum time. So that, he can go back home earlier and his mother will not blame him. The streets ShaDan visited is very strange. They are all one-way streets. All the cars on a street is drived along in one direction. But ShaDan can walk around the street in two directions. For example , if the street is from city i to city j , cars can only be drived on the street from the city I to city j. But ShaDan can walk around the street from the city i to city j and also can walk around the street form the city j to city i . In addition , ShaDan have a Super-capacity. Every move , he can choose a city i , and it doesn’t cost time. When he is in a city I,he have two ways to visit the streets. nThe first one :he is in the city i , and he can walk around all the streets that from the city i ( for example i= 2 , he can walk 2->5, 2->3 , 2 - >6 ,if there exists a street ), it will costs he Wi to visit all the streets from city i.nThe second one : he is in the city i, and he can walk around all the streets to city I ( for example i= 2 , he can walk 5->2, 4->2 , 3 - >2 ,if there exists a street ), it will costs he Pi to visit all the streets to city i.nAlthough ShaDan have a Super-capiacity , but his IQ is very low. nHe is unable to deal with the problem . So he asked his best friends RPRUSH to help him to calculate the minimum time to visit all the streets.n nnInputnInput contains multiple test cases. Each test case contains an integer N (1 <= N < = 300 , the number of city) and M (1 <= m <= 20000, the number of streets )in a line first line , the second line contain n integers( from W1 to Wn ). The third line contain n integers (from P1 to Pn). Then followed M line, each line contain two integers a and b , means there is a street from city a to city b.nIf there are two or more streets from city a to b , it is also legal. The input ends with a line that has two non-positive numbers.n nnOutputnFor each input case ,output a line containing a single number, which is the minimum time it need to visit all the streets.n nnSample Inputn3 3n1 2 4n4 1 3n1 2n2 3n3 1n0 0n nnSample Outputn7 问答

没有更多推荐了,返回首页