以下所有语言的标准是否产生值3?
Print(6 - 2 - 1)
Run Code Online (Sandbox Code Playgroud)
换句话说,是否有任何语言会在"6 - 2"之前评估"2 - 1"吗?
我想做出这个假设,这样我就可以本能地插入括号((6 - 2) - 1).这让我有可能遭受LISP的噩梦.
谢谢
例如,我想减去获得小时和分钟(不是日期)结果的时间
02/26/2006 06:25 PM
减去
02/26/2006 06:23 PM
成
2分钟
此外,我想减去的时间是字符串,而不是日期时间对象.
我想知道如何在C中"减去字母":
我的意思是,我有两个字母,'a'和'c',我想执行'c' - 'a'='b',这是3-1 = 2.
如何在C中获得相同的行为?
我可以转换字母 - >数字,但如何管理字母表的有限长度?谢谢.
这段代码有什么错误?当我运行该程序时,它说"应用程序buttonProj(进程com.example.buttonproj)已意外停止.请再试一次"我刚尝试创建一个Add and Subtract按钮,用户可以点击它来增加或减少数字i .
package com.example.buttonproj;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends Activity {
int counter;
Button add, sub;
TextView display;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
counter = 0;
add = (Button) findViewById(R.id.bAdd);
sub = (Button) findViewById(R.id.bSub);
display = (TextView) findViewById(R.id.textView1);
add.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
counter +=1;
display.setText(counter);
}
});
sub.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { …Run Code Online (Sandbox Code Playgroud) 所以你可以看到我有一个价格和日期列在下面
Price Day
2 1
5 2
8 3
11 4
14 5
17 6
20 7
23 8
26 9
29 10
32 11
35 12
38 13
41 14
44 15
47 16
50 17
53 18
56 19
59 20
Run Code Online (Sandbox Code Playgroud)
然后我想要下面的输出
Difference Day
12 5
15 10
15 15
15 20
Run Code Online (Sandbox Code Playgroud)
所以现在我每5天就有不同的价格...它基本上是第一天减去第5天.....然后是第5天等第10天......我已经制作了一个代码将我的数据分成5天的时间间隔......但我希望代码能让我减去第5天的第5天......第5天的第10天......等等所以代码应该看起来像这样
difference<-tapply(Price[,1],Day, ____________)
Run Code Online (Sandbox Code Playgroud)
所以基本上Price [,1]将是我的价格数据.....而"Day"是我创建的变量,它将让我将我的Day数据分成5天的间隔.....我在想空白部分我可以放入功能或另一个变量,让我减去第5天的第1天价格,然后第10天和第5天的价格...等.....你没有必要帮助我将我的日子分成几个间隔...如何做"差异"部分....谢谢你们
我正在使用32位系统并在EDX中保存了64位数:EAX.我正在尝试减去ESI中保存的数字:EDI是正确的吗?我很确定它不是因为经过3次迭代后结果不正确.
sub %esi, %edx #Subtract two 64 bit numbers
sub %edi, %eax
Run Code Online (Sandbox Code Playgroud) 我试图在Python中减去字母,但我不能以正确的方式做到这一点.
我知道如何得到ord这封信.
喜欢:
a = "a"
x = ord(a) # -> this will give me 97.
Run Code Online (Sandbox Code Playgroud)
当我尝试从该字母中减去值时,得到的结果与我想要的完全不同.
如果我减去1从b我得到的97(代表a),但现在我想减去14从b,我想达到a,然后回去z,继续减法.
a = 97
b = 98
...
z = 122
Run Code Online (Sandbox Code Playgroud)
我想继续循环使用小写字母,它位于97和之间122.
例如,如果我减去14从b,我得到的84,但我想这样做,我想获得的方式n.
b - 14 = a - 13 = z - 12 (...) and so on.
Run Code Online (Sandbox Code Playgroud)
我希望你能理解我的意思.
;)
有人能帮我一下吗 ?
此致,伊万.
问题有点严重.我需要的输出是2.9558577807620168e-12.
1个#working.php
<?php
$a = 465.90928248188;
$b = 15.651243716447;
$c = 450.25803876543;
echo $a - $b -$c // output 2.9558577807620168e-12 as expected
?>
Run Code Online (Sandbox Code Playgroud)
2#notworking.php
<?php
lot of arithmetic calculation almost 200-250 LoC
$array1_28x1[3]; // 465.90928248188
$array2_28x1[3]; // 15.651243716447
$array3_28x1[3]; // 450.25803876543
echo $array1_28x1[3] - $array2_28x1[3] - $array3_28x1[3];
// output -4.5474735088646E-13
?>
Run Code Online (Sandbox Code Playgroud)
我不明白这是什么问题.可以是内存泄漏吗?我已经一步一步调试,但找不到任何解决方案.这是非常重要的计算,所以甚至不能忽视.
注意:在250 LoC下变量的值没有变化.我在减法之前已经转储了变量.
我听说R中的循环很慢,所以我想知道如何简化这个以加快速度.我想从连接中的每个元素中减去1,但如果它已经为零,我不想继续减去并使其为负数.
for(i in 1:length(connections)) {
if(connections[i] > 0) {
connections[i] = connections[i] - 1
}
if(connections[i] < 0) {
connections[i] = 0
}
}
Run Code Online (Sandbox Code Playgroud) I am trying to subtract 2 pointers such that they such give the number of elements.I could compile the program and run it .But after compilation it is throwing error as
Run Code Online (Sandbox Code Playgroud)pointerarithmetic.c: In function ‘main’: pointerarithmetic.c:9:8: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=] printf("%d",(q-p));
The code:
#include<stdio.h>
int main(){
int a[5]={0,10,20,30,40};
int *p,*q;
p=&a[0];
q=&a[2];
printf("%d",*p);
printf("%d",*q);
printf("%d",(q-p));
return 0;
}
Run Code Online (Sandbox Code Playgroud)
The expected output should be number of elements.
subtraction ×10
c ×2
math ×2
r ×2
add ×1
android ×1
assembly ×1
coldfusion ×1
coldfusion-8 ×1
extract ×1
for-loop ×1
java ×1
optimization ×1
php ×1
pointers ×1
python ×1
time ×1
vector ×1
x86 ×1