很抱歉我问了这么愚蠢的问题,但我不能理解,因为它太简单了。
当我尝试以下代码时,Excel 2010停止运行:
Sub Delay()
Dim j As Double
Dim i As Double
Dim k As Double
For i = 1 To 1000000
j = Sqr(i)
k = 0
Do While k < 1000000
j = Sqr(k)
k = k + 1
Loop
Next
End Sub
这个潜水艇什么也不做,只是花时间
我只是第一次学习Java,我不明白为什么我的总和不能从用户的输入中正确地显示出来。任何帮助都将不胜感激!
System.out.println("Enter an income (Any negative number to quit):");
ArrayList<Double> numbers = new ArrayList<>();
Scanner one = new Scanner(System.in);
double sum = 0.0;
double avg = 0.0;
while (tru
我是编程新手,我正在尝试打印fabonacci序列,我不能理解为什么不从while循环条件中减去7就无法得到正确的输出。有谁能告诉我如何解决这个问题。
#include<iostream>
#include<cmath>
using namespace std;
int main (){
double y;
double z;
int x;
cout <<"Enter the number you want to find the sequence of :";
cin>>x;
当我运行大量数据集时,我遇到了性能问题。为了简单起见,我写下了以下代码:
double *a = new double();
for (int i = 0; i < 1000000; i++){
double x = 0;
double y = 0;
for (int j = 0; j < 1000; j++){
x = 1000;
y++;
}
*a = x; //*a = y;
}
这需要近0毫秒。但是,如果我将y指定为*a,则:
double *a = new double();
for (int i
这是我第一次使用C++,我正在编写一个小程序来总结多达十个数字(双倍),这些数字将在命令提示符中输入。
我已经编写了下面的代码,我不知道为什么它不会产生期望的结果。
int main()
{
double num[10];
double sum = 0;
int i;
int n = 10;
while (scanf_s("%lf", &num) != EOF)
{
for (i = 0; i < n; ++i)
{
scanf_s("%lf"
我试着为模数写一段代码,但是当我对负数这样做时,我得不到正确的结果,我的代码:
double mod (double X, double Y)
{
double result = X;
if (X>0){
do
{
result = result - Y;
}while(result >= Y);
}
if (X<0){
do
{
result = result + Y;
}while(0 >= result);
}
}
当你做像mod(-5,2
我一直试图在代码块中运行这个普通的计算器程序,它构建时没有错误,但是由于某些原因不能运行,我不知道为什么。我的代码在下面
#include < iostream >
using namespace std;
double getAverage(int amount, int numbers[]) {
// Declare the variables
int total = 0;
double avg = 0;
//Find each number in the array then add it to the total
for (int i = amo
这是我的代码,在其中我声明了一个包含所有值的2d数组,并且我试图让它打印出min和max值。最大值结果正确,但最小值不正确。当我运行它时,最大值是9.73 (这是正确的),而打印的最小值是5.44,这是不正确的,因为如果查看数组中的值,就会看到5.29是最小值。有人知道为什么它找不到正确的min值吗?提前感谢!
public class Test {
public static double[][] array1 = //array to be used
{{7.51, 9.57, 6.28, 5.29, 8.7},
{8.07, 6.54, 5.44, 8.78, 8.66
我在AP计算机科学,我们刚刚学会了如何使用我们自己的静态方法。这是我使用它们的第二个程序,但这一次涉及到数组,而且我得到了非常奇怪的输出。我希望有人能帮我找出原因,我假设我没有正确地返回结果数组。
这个程序的目的是计算太阳系内所有行星的表面引力。我需要帮助的两件事是:
我不知道如何使用printf()格式化科学表示法,所以这真的很糟糕。
我的重力数组包含每个数字的[D@7248989f,我不知道为什么。
public static double[] surfaceGravity (double[] r,double[] m) {
double[] g = new d
我有一个像List<dynamic> is not a subtype of List<double>这样的错误,但这里的问题是List<double>是在运行时确定的,我这样做: extension Ext<T> on List<T> {
List<T> deepClone() {
List<T> res = [];
for (var value in this) {
if (value is List) {
res.add(value.deepClone()
我编写了一个简单的for循环:
>> for m=1:3
p=m;
end
>> whos
Name Size Bytes Class
m 1x1 8 double array
p 1x1 8 double array
但是,当我试图为某个范围创建相同类的数据类型并检查您现在存储的变量不是1x1大小时:
>> k=1:256;
>> whos
Na
在DEV-C++中,我试图创建一个简单的函数来将存储在辅助函数中的值返回给主函数,但我不确定为什么它不能工作:/
我真的觉得它应该正确运行,但当我编译和运行程序时,它没有要求输入值,并显示了0和语句中的句子,当0是输入值时。
// This program asks user to enter IQ score and then displays a message
#include<iostream>
using namespace std;
double getIQ();
int main()
{
double iq = 0.0;
getIQ();
class Example {
public static void main(String args[]) {
double nums[] = {10.1, 11.2, 12.3, 13.4, 14.5};
double result = 0;
int i;
for(i=0; i<5; i++)
result = result + nums[i];
System.out.println("Average is " + result / 5);
}
}
如果这个问题
private List<Double[]> bestPoints(List<Double[]> includedPoints) {
List<Double[]> bestPoints = new ArrayList<Double[]>();
int a = includedPoints.size();
for (int i = 0; i < a; i++) {
Double[] tempPoint = includedPoints.get(i);
所以我不能让这一小段代码工作,我不确定为什么它不能...
String rawInput = JOptionPane.showInputDialog("Please enter the three side lengths seperated by spaces.");
double[] hold = double.parseDouble(rawInput.split(" "));
我有一个想法,首先使用另一个字符串数组将值放入,然后使用for循环和double.parseDouble()将它们放入双精度数组,但对于我想要做的事情来说,这似乎过于复杂了。
我为无限循环编写了一个程序,如下所示,并不断地分配新内存
#include<iostream>
using namespace std;
int main()
{
for (int i = 0; ; ++i)
{
double* x = new double[2000];
*x = i * 2.5;
cout << i <<" "<< *x << endl;
}
return 0;
}
它成功地运行了,并在结尾处结束时说: bad_a
在使用递归函数的一维谐振子上工作,代码在fortran中工作,并试图转换为C++以学习新的语法。
到目前为止,我已经通过google修复了所有已通知的错误,但仍然没有得到结果。该程序似乎永远运行,没有发布结果。
我认为可能的答案可能是它根本没有被计算,或者因为我的for循环或被调用的函数中的语法问题而导致了无穷大的循环?但我没有看到这一点,也没有发现他们的错误。
对于为什么这个程序不能正常工作,有什么建议吗?
//
// main.cpp
// 1-d HO
//
// Created by Grant Metheny on 3/2/16.
// Copyright (c) 201