At lines 25 and 32, remove the semicolon. Because of those semicolons, max and min are both assigned to the final number in the array.
At lines 25 and 32, remove the semicolon. Because of those semicolons, max and min are both assigned to the final number in the array.
What VBox settings are recommended for Win 8? Win 8 is very slow when I use VBox.
Wikipedia says it is called "caret"
I tested it and it worked. Server on Windows 7 x64, IP 192.168.1.50, Client on Virtualbox Guest Windows XP IP 192.168.1.51
I haven't tested it yet using my router's external IP address. I'm not at home right now, and I can't access the router I'm currently using, so I can't port forward 12345 to my laptop. :) I'll be testing it once I get home.
Should be for(int i=list.size()-1;i>=0;i--)
There are probably some people out there that create these things for the sole sake of annoying others.
Perhaps runway3 is empty at that point? Like pyTony said, you should first check each runway if it is empty or not before trying to get the top. Because if a runway is empty, the top of it is a nonetype which will give you that error.
Btw, at line 29 of your code, it should be h[i]=(n[i+1]-n[i])
Isn't it because you used mo[j-1]
instead of mo[j]
?
Oh, now I know why you're getting out of ranges and nonetype elements. You confused the element number with the length. Suppose you create a list x with length 5. Wouldn't the contents of x be (0 to 4)? Or to put it another way, if you create a list x with elements (0 to 5), wouldn't the length be 6? Meaning, for any list x with elements (0 to n), len(x) = n+1. Let's go over the steps in the wikipedia page (note in the following statements, I renamed your list n to list x to avoid confusion with the element n):
Step 1:
a)Create array a with size n+1 (n being the index), or in other words, with size len(x). But you defined a with size len(x)+1
Step 2: arrays b and d with size n, or len(x)-1. But you defined them with size len(x)
Step 3: array h with size n, or len(x)-1 - same as step 2
Step 4: array g with size n - same as step 2
Step 5: arrays c, lo, mo, zo with size n+1 or len(x) - same as step 1
Step 6: you've done it ok
Step 7: for i = 1,...,n-1 which translates to for i in range(1,len(x)-2)
but you wrote for i in range(1,len(x)-1)
Step 8: lo(n), zo(n) and c(n) or lo(len(x)-1), zo(len(x)-1) and c(len(x)-1) respectively, but you wrote lines 50 to 52 instead
Step 9: for j = n-1, n-2,...,0 which translates to for j in …
Strange, I'm not encountering any error, except the unindent issues at lines 63 to 66.
On second thought, it's not definite that I could recreate those errors in my own code. Is it possible for you to post the rest of the code?
Use a counter that increments whenever isprime is 1. Once the counter is equal to the input x, display the value you sent to isprime.
Hmm lemme compile the code. Unfortunately I'll have to recreate the rest of the code so it'll take some time.
Anyway, on your problem is that for every else if
statements, you added a semicolon after the condition. You are not supposed to do that. Additionally, you're missing another equal sign at line 53.
Do arrays m and n have fixed sizes? If so, what are the sizes? If not, is it possible for len(m) to be greater than or equal to len(n) - 2?
Could you check the Power Options and see when (or if) the display is set to dim and/or turn off? What OS are you using?
Your array of n has a maximum index of len(n) - 1. Your counter i ranges from 0 to len(n) - 1. So far so good. However, at line 14, you're trying to access the (i+1)th element of array n. What happens once i = len(n)-1? i would be equal to len(n), which exceeds the maximum available index of len(n)-1, hence the index out of range.
@pyTony I think m and n are already defined, just not included in the "part" of the code s/he posted here. I may be wrong though.
Oh, sorry I thought you wrote getch and not getchar. getchar doesn't work because it reads a stored newline in the buffer. Depending on the condition of your if statement, if((c=getchar())=='\n')
will force the program to continue to lines 53 and after, while if((c=getchar())=='\r')
will skip those lines and go directly to line 69. On neither situations will the program wait for an input from you at line 51. The program waits for you to press any key before it ends because line 69 contains getch();
Instead, at line 51, use if((c=getch())=='\r')
or even just if(getch()=='\r')
works.
Yes, that's correct.
What do you mean by you have written a method which returns the result as a string? Can you post that? Maybe we can start from that.
The keyboard's Enter key gives a combination of two characters: carriage return (\r, ascii=13) and newline (\n, ascii=10). Since you're reading only one character, the character that is read is the first one which is carriage return. Look them up for their functions :) (Forgot to mention the combination is for Windows systems. Other systems may differ)
Try changing line 51 with if((c = getch())==13)
, 13 being the ascii of the character of carriage return.
Just use an if-else statement and a pair of counters within one of the for loops. (preferably the 2nd for loop)
That happens because you are trying to access the elements of an empty vector. You could do two things: first would be to resize the vector after you input the number of students (syntax: Grades.resize(num);
or, initialize the vector entirely after the number of students is entered (aka move line 9 to line 15, and include num as the size)
for(i = 0; i < num; i++);
The character array pass
cannot find a null value after the last password character. It will continue to read beyond the last character until it finds a null value (on or before the 30th byte after the first character). That is why the pass read at Line 93 may include additional garbage characters, hence the inequality with the password read in the file. To rectify it, add a pass[i] = 0;
between lines 88 and 89 to let the program know where the true password ends.
Are you looking for something similar to this?
"Select SequenceID, a.FirstName + ' ' + a.Secondname AS Dispatcher, b.FirstName + ' ' + b.Secondname as Technician from Dispatch, Employee a, Employee b where DispatchID like a.EmployeeID and TechnicianID like b.EmployeeID order by SequenceID"
Also, shouldn't lines 44 to 85 be included inside a function?
menu() is supposed to return an int, but it currently returns choice which is a char.
Here it is. I hadn't thought using scientific notation for the really large numbers, nice idea. I dunno how to balance accuracy vs practicality. This will continue to print every single number of every single stn from 0 to input. If I were to use scientific notation, I'll probably leave a hundred digits before the 10^x. Probably even more >.< Anyway, it takes prolly 4 secs to get the first 1000, and each stn after that takes more time to print because the number of digits keep increasing. Takes 6 mins for 10000 in my laptop.
import java.util.*;
import java.math.*;
public class FunLoops {
Scanner in;
BigInteger [] arr;
BigInteger two = new BigInteger("2");
BigInteger thirtyfour = new BigInteger("34");
int input;
public FunLoops() {
in = new Scanner(System.in);
run();
}
public void run(){
System.out.println("How many square triangular numbers do you want printed?");
input = in.nextInt();
arr = new BigInteger[input];
for(int i=0; i < input; i++){
rec(i);
System.out.println("Square Triangular Number #" + (i) + ": " + arr[i]);
}
}
public void rec(Integer i){
long total;
if(i == 0){
arr[0] = BigInteger.valueOf(0);
}else if(i == 1){
arr[1] = BigInteger.valueOf(1);
}else{
arr[i] = thirtyfour.multiply(arr[i-1]).subtract(arr[i-2]).add(two);
}
}
}
Ok. I tried the code, typed in 50 as input and got the first 50 in an instant. Even with 100 as input, it gives out everything instantaneously.
Create a dynamic bigint array, initialize it with size input, and modify the rec function. I have actually created the code, just have to test it. I'll post it if it works. By the way, did you really get the first 30 stns instantly? I got the first 10 instantly, had to wait a couple of seconds for 11th, a little longer for 12th and I didn't have the patience to wait for 13th.
Ok. First, since you used the syntax thines01 posted, there's no more need for an arr array. However, you could use arr as a string. So, you can remove those []
at line 9 now. Next, you're not supposed to replace string.join with arr.join. You are supposed to assign string.join to arr. arr = string.Join(",",files.ToArray());
Then follow my previous post (both lines 43 and 67), but disregard parts with the ","
, and the newline/return combo.
Are you supposed to send the list itself? Or merely a string representation of the list? If it's the latter, you should change a few things.
At line 43: You created a string, but you did not assign it to a string variable.
Additionally, the ","
part decides how the list should like like. At present, each filename would be separated by a comma:
filename1,filename2,filename3,....
If you wanted to make it more like a list like:
filename1
filename2
filename3
...
then replace that comma with a newline/carriage return combo.
At line 67: simply replace files
with the string variable you are supposed to use at line 43.
So you are saying that the sequence of characters for array1 and array2 are already decided? In that case, your input string should be converted into a character array. Use a loop going through array1 to find the index of each character in the input, use that index to get the corresponding character from array2 and append that character to the output string.
To reprhase thines01's post:
convert your list of strings (aka files) into a string array (let's say, arr) using .ToArray(), combine all elements of this new array into a single string using string.Join, and assign that to a new string variable. thines01's post has the syntax.
Probably because at line 43, you used int(x) instead of just x? x at that point far exceeds the max value for an integer.
Also, at the example you posted above, total/x are long and incrementer is float.
These are just guesses.
I've tried only two types for incrementer (float and long), and kept total as long. The thing is, when incrementer was float which is 4 bytes, it probably converts total from long (8 bytes) into float, add incrementer to it, then convert back to long. Maybe the conversion causes loss of the upper bits and therefore gives out an incorrect value. It probably goes the same with int, which is also 4 bytes. (I've never tried int in your program). That is probably why these two types give the wrong output despite total not reaching its max value. With incrementer as long or double, which is another type with 8 bytes, total will not be converted down, and thus, no loss of accuracy. However, they may reach maximum value and give out the wrong output. (For long, you and I both have experienced having negative output, which means that, being signed, it exceeded the max positive value) (For double, I have not tried it but you said it kept printing out the max value)
Probably because the arr array points to the same array as sequence, and there is no null value at the end of the intended sequence array? That is probably why it outputs beyond the intended sequence, including gibberish until it finds a null value. Just my two cents.
I have a friend that experienced having a malware that forces windows explorer to report that his hard drive is almost full, although only half of it is used. Maybe you're experiencing the same?
No, all the if statements are individual. Nothing nested. Something like:
if(a<=b){
a = a + b;
b = a - b; //switches a with b
a = a - b;
}
if(a<=c){
a = a + c;
c = a - c; //switches a with c
a = a - c;
}
and so on
For 5 numbers, it can be done. All you have to do is place the lowest (or highest) number into a, using four if statements (compare a with b,c,d and e, then switching each time a is less (or greater) than one of those). Follow it up with comparing b to c,d and e (three if statements, making it seven total). Lastly, compare c with d and e (two statements, making it nine statements total). Since you're looking for the median in a group of five numbers, you will need the third number, which is c. You don't have to compare d and e (and even if you do, it takes just an additional one if statement, making a total of 10).
Also, to alternate the symbols (going down) if the size is even, just add 1 to other before the for loop.
Have you tried ommitting the IN? Or if Score is a string, then make it operator & "' & Score & "'"
Hmmm provided the value in the combobox corresponds to a valid field in the database, no matter the value of s, it should not generate an error (which means you don't need to check the value of s). If however, the combobox doesn't, then it becomes an error. I assume your combobox style is a dropdown combo, such that you could enter any value in it, or that at runtime its original value is -1 and you search before changing it.
Things you could do: a) make it a dropdown list style, and at Form_Load, add combo1.listindex = 0; or b) like BitBlt said, write a code that checks whether the value selected in the combobox corresponds to a field in the database. You can do this by using an if-and-then statement.
Installed fine for me in VirtualBox just now. Kinda slow though :X I'm still checking out things here.
As long as the entry is a date or a string which resembles a date and includes a year, there should be no mismatch.
Hmm I just wanna check something. If you add an "On error resume next", does Label15 get filled with a date? Also, just for testing purposes, could you comment those datediff lines, and add a button which does the datediff line? Like:
Private Sub cmdnxt_Click()
Adodc1.Recordset.MoveNext
'Label16.Caption = DateDiff("YYYY", Label15.Caption, Now)- type mismatch
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveLast
MsgBox "End of File", vbInformation
End If
End Sub
Private Sub cmdprvs_Click()
Adodc1.Recordset.MovePrevious
'Label16.Caption = DateDiff("YYYY", Label15.Caption, Now)- type mismatch
If Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveFirst
MsgBox "Begin of file", vbInformation
End If
End Sub
Private Sub Command1_Click()
Label16.Caption = DateDiff("YYYY", Label15.Caption, Now)
End Sub
Please see what happens after you click the new button, with a date already placed in Label15.