Recursion with array
hi
i got this question , int values[] int index int amount i need to check if there is sum of elementv in values that equal to amount
example
values[]={5,22,13,5,7,-4}
amount=31
22+13+(-4)=31
return true
the signature fo function call in recursion is:
cover (int[] values,int i,int amount)
henvertis, you hijack someone else's thread to post your "question". I suggest you to create a thread of your own and tell you that it might be a good idea to post the code you're working on because just posting a description of the problem might result into other forum members assuming you just want someone to do it for you (some call this cheating).
You then create a new thread, but (again) just with the problem description. I respond to that thread but you never got back to me, and now you're back again with another new thread and again just the problem description!
What's wrong with you?
Similar Messages
-
Hi,
I am having trouble with creating a recursive method to sum all
elements in an array. I am new to recursion and am getting
confused.
Here is a method I am working with:
I am trying to sum all the sides of a triangle whose sides
are stored in the array sides [ ], but can't seem to add
more than the sides[2] and sides[1] elements.
Any ideas? One of the requirements is that 0<= index < size or array.
Thanks,
int perimeter() {
return perim(0);
int perim(int index) {
if (index == sides.length-1)
return sides[index];
else{
int sidesTotal = perim(index+1);
return sidesTotal + sides[index-1];
}> I am having trouble with creating a recursive method
to sum all elements in an array.
class ReallyBadUseOfRecursionDemo {
public static int recursiveSum(int[] array) {
if (array == null || array.length == 0) return 0;
if (array.length == 1) return array[0];
return array[0] + recursiveSum(java.util.Arrays.copyOfRange(array, 1, array.length));
public static void main(String[] args) {
assert 0 == recursiveSum(null);
assert 0 == recursiveSum(new int[0]);
assert 42 == recursiveSum(new int[] { 42 });
assert 6 == recursiveSum(new int[] { 1, 2, 3 });
}~ -
Recursive MISO (Array)
Hello. I have problem with recursive MISO Array. Stimulus is 2D array and response is 1D array. This arrays are same lenght.After run write error 20 002. I don't know where is a problem. Please help me. Thanks
Hey Mizda,
Your B matrix and Delay matrix were incorrect.
The B matrix should be scalar, and Delay matrix should be initialized (it can be 'zero', but it can't be empty).
Please, check this simple example!
Best regards,
Matyas
Attachments:
TroubleshootIdentifikace_Simple.vi 19 KB -
Hi,
I have a MBP 13' Late 2011 and Yosemite 10.10.2 (14C1514).
Until yesterday, I was using Garmin ConnectIQ SDK and all was working fine.
Yesterday, I've updated my system with latest security updates and Xcode updates too (Version 6.2 (6C131e)).
Since, I can't launch the ConnectIQ simulator app, I have this message in console :
8/04/2015 15:19:04,103 mds[38]: There was an error parsing the Info.plist for the bundle at URL Info.plist -- file:///Volumes/Leto/connectiq-sdk-mac-1.1.0_2/ios/ConnectIQ.bundle/
The data couldn’t be read because it isn’t in the correct format.
<CFBasicHash 0x7fa64f44e9a0 [0x7fff7dfc7cf0]>{type = immutable dict, count = 2,
entries =>
0 : <CFString 0x7fff7df92580 [0x7fff7dfc7cf0]>{contents = "NSDebugDescription"} = <CFString 0x7fa64f44f0a0 [0x7fff7dfc7cf0]>{contents = "Unexpected character b at line 1"}
1 : <CFString 0x7fff7df9f5e0 [0x7fff7dfc7cf0]>{contents = "kCFPropertyListOldStyleParsingError"} = Error Domain=NSCocoaErrorDomain Code=3840 "The data couldn’t be read because it isn’t in the correct format." (Conversion of string failed.) UserInfo=0x7fa64f44eda0 {NSDebugDescription=Conversion of string failed.}
I have looked at this file and it looks like a binary plist
bplist00ß^P^V^A^B^C^D^E^F^G^H
^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_ !"$%&'()'+,^[\CFBundleNameWDTXcodeYDTSDKName_^P^XNSHumanReadableCopyrightZDTSDKBuild_^P^YCFBundleDevelopmentRegion_^P^OCFBundleVersi on_^P^SBuildMachineOSBuild^DTPlatformName_^P^SCFBundlePackageType_^P^ZCFBundleShortVersionString_^P^ZCFBundleSupportedPlatforms_^P^]CFBundleInfoDictionaryVersion_^P^RCFBundleE xecutableZDTCompiler_^P^PMinimumOSVersion_^P^RCFBundleIdentifier^UIDeviceFamily_^P^QDTPlatformVersion\DTXcodeBuild_^P^QCFBundleSignature_^P^ODTPlatformBuildYConnectIQT0611[iph oneos8.1o^P-^@C^@o^@p^@y^@r^@i^@g^@h^@t^@ ^@©^@ ^@2^@0^@1^@5^@ ^@G^@a^@r^@m^@i^@n^@.^@ ^@A^@l^@l^@ ^@r^@i^@g^@h^@t^@s^@ ^@r^@e^@s^@e^@r^@v^@e^@d^@.V12B411RenQ1V14C109Xiphoneos TBNDLS1.0¡#XiPhoneOSS6.0YConnectIQ_^P"com.apple.compilers.llvm.clang.1_0S8.1_^P^Tcom.garmin.ConnectIQ¡*^P^AW6A2008aT????^@^H^@7^@D^@L^@V^@q^@|^@<98>^@ª^@À^@Ï^@å^A^B^A^_^A?^AT^ A_^Ar^A<87>^A<96>^Aª^A·^AË^AÝ^Aç^Aì^Aø^BU^B\^B_^Ba^Bh^Bq^Bv^Bz^B|^B<85>^B<89>^B<93>^B¸^B¼^BÓ^BÕ^B×^Bß^@^@^@^@^@^@^B^A^@^@^@^@^@^@^@-^@^@^@^@^@^@^@^@^@^@^@^@^@^@^Bä
I guess it is a normal format but my system seems to be unable to read binary plist ?
I tried some stuff with plutil
plutil -lint Info.plist
Info.plist: Unexpected character b at line 1
Same for convert
plutil -convert xml1 Info.plist
Info.plist: Property List error: Unexpected character b at line 1 / JSON error: JSON text did not start with array or object and option to allow fragments not set.
I also try to download a fresh version of the connectIQ SDK and no changes.
Any idea ?
ThanksStep by step, how did you arrive at seeing this agreement?
-
Hello.
During developing Domain Index for Oracle 11.2.0.1.0 (problem also appears in 12с) i was faced with misunderstanding of parameter types of function
ODCIIndexInsert in case of creating indextype WITH ARRAY DML option
According to Oracle documentation
http://docs.oracle.com/cd/E11882_01/appdev.112/e10765/ext_idx_ref.htm#i76892
In case of WITH ARRAY DML option Oracle will invoke ODCIIndexInsert with following signature
FUNCTION ODCIIndexInsert(
ia ODCIIndexInfo,
ridlist ODCIRidList,
newvallist varray_of_column_type,
env ODCIEnv)
RETURN NUMBER
In my case indexed column has datatype NUMBER so i defined varray_of_column_type as SYS.ODCINumberList
STATIC FUNCTION ODCIIndexInsert(ia in sys.ODCIIndexInfo, ridlist in sys.ODCIRidList, newvallist in sys.ODCINumberList, env in SYS.ODCIEnv) RETURN NUMBER
Indextype was created as
CREATE INDEXTYPE test_index_type
FOR
test_eq(number, number)
USING index_methods
WITH ARRAY DML(number, sys.ODCINumberList)
WITH LOCAL RANGE PARTITION
WITH SYSTEM MANAGED STORAGE TABLES;
or
CREATE INDEXTYPE test_index_type
FOR
test_eq(number, number)
USING index_methods
WITH ARRAY DML
WITH LOCAL RANGE PARTITION
WITH SYSTEM MANAGED STORAGE TABLES;
(problem occurs in all cases)
CREATE TABLE test_table (id NUMBER (19,0));
CREATE INDEX test_index ON test_table(id) INDEXTYPE IS test_index_type;
When attempting to insert data in the table
insert into test_table values (1);
oracle raise exception
Error starting at line 53 in command:
insert into test_table values (1)
Error at Command Line:53 Column:1
Error report:
SQL Error: ORA-29925: cannot execute SCOTT.INDEX_METHODS.ODCIINDEXINSERT
ORA-06553: PLS-306: wrong number or types of arguments in call to 'ODCIINDEXINSERT'
ORA-06553: PLS-306: wrong number or types of arguments in call to 'ODCIINDEXINSERT'
29925. 00000 - "cannot execute %s"
*Cause: The specified function does not exist or does not have an
appropriate signature.
*Action: Implement the function with the appropriate signature.
So my question is.
Is it normal behavior of oracle (according to documentation)?
What is correct signature of ODCIIndexInsert function in case of INDEXTYPE creation with 'WITH ARRAY DML' option and fact that indexed column has NUMBER datatype?
By the way if i define indextype without 'WITH ARRAY DML' option signature is clear, and working. But this approach doesn't satisfies our performance needs.
Also if i define index type with option 'WITH ARRAY DML WITHOUT COLUMN DATA' and use signature
static function ODCIIndexInsert(ia sys.odciindexinfo, ridlist sys.odciridlist, env sys.ODCIEnv) return number
Everything works too. But this approach doesn't satisfies our business needs.
Is it a way to define ODCIIndexInsert parameter types (in case of indexing number column) so that batch inserting works according to documentation ?
FUNCTION ODCIIndexInsert(
ia ODCIIndexInfo,
ridlist ODCIRidList,
newvallist varray_of_column_type,
env ODCIEnv)
I am attaching full sql script to recreate environment and reproduce the problem.
Type definition:
CREATE OR REPLACE TYPE index_methods AS OBJECT
step number,
STATIC FUNCTION ODCIGetInterfaces(ifclist OUT SYS.ODCIObjectList) RETURN NUMBER,
STATIC FUNCTION ODCIIndexCreate (ia SYS.ODCIIndexInfo, parms VARCHAR2, env SYS.ODCIEnv) RETURN NUMBER,
STATIC FUNCTION ODCIIndexAlter (ia sys.ODCIIndexInfo, parms IN OUT VARCHAR2, altopt number, env sys.ODCIEnv) RETURN NUMBER,
STATIC FUNCTION ODCIIndexDrop(ia SYS.ODCIIndexInfo, env SYS.ODCIEnv) RETURN NUMBER,
STATIC FUNCTION ODCIIndexExchangePartition(ia SYS.ODCIIndexInfo, ia1 SYS.ODCIIndexInfo, env SYS.ODCIEnv) RETURN NUMBER,
STATIC FUNCTION ODCIIndexUpdPartMetadata(ia sys.ODCIIndexInfo, palist sys.ODCIPartInfoList, env sys.ODCIEnv) RETURN NUMBER,
STATIC FUNCTION ODCIIndexInsert(ia in sys.ODCIIndexInfo, ridlist in sys.ODCIRidList, newvallist in sys.ODCINumberList, env in SYS.ODCIEnv) RETURN NUMBER,
STATIC FUNCTION ODCIIndexDelete(ia SYS.ODCIIndexInfo, rid VARCHAR2, oldval number, env SYS.ODCIEnv) RETURN NUMBER,
STATIC FUNCTION ODCIIndexUpdate(ia SYS.ODCIIndexInfo, rid VARCHAR2, oldval number, newval number, env SYS.ODCIEnv) RETURN NUMBER,
STATIC FUNCTION ODCIIndexStart(sctx IN OUT index_methods, ia SYS.ODCIIndexInfo,
op SYS.ODCIPredInfo, qi sys.ODCIQueryInfo, strt number, stop number, cmpval number, env SYS.ODCIEnv) RETURN NUMBER,
MEMBER FUNCTION ODCIIndexFetch(self IN OUT index_methods, nrows NUMBER, rids OUT SYS.ODCIridlist, env SYS.ODCIEnv) RETURN NUMBER,
MEMBER FUNCTION ODCIIndexClose(self IN index_methods, env SYS.ODCIEnv) RETURN NUMBER
CREATE OR REPLACE TYPE BODY index_methods IS
STATIC FUNCTION ODCIGetInterfaces(ifclist OUT sys.ODCIObjectList) RETURN NUMBER IS
BEGIN
ifclist := sys.ODCIObjectList(sys.ODCIObject('SYS','ODCIINDEX2'));
RETURN ODCIConst.Success;
END ODCIGetInterfaces;
STATIC FUNCTION ODCIIndexCreate (ia sys.ODCIIndexInfo, parms VARCHAR2, env sys.ODCIEnv) RETURN NUMBER IS
BEGIN
RETURN ODCIConst.Success;
END ODCIIndexCreate;
STATIC FUNCTION ODCIIndexDrop(ia sys.ODCIIndexInfo, env sys.ODCIEnv) RETURN NUMBER IS
BEGIN
RETURN ODCIConst.Success;
END ODCIIndexDrop;
STATIC FUNCTION ODCIIndexAlter (
ia sys.ODCIIndexInfo,
parms IN OUT VARCHAR2,
altopt NUMBER,
env sys.ODCIEnv)
RETURN NUMBER IS
BEGIN
RETURN ODCIConst.Success;
END ODCIIndexAlter;
STATIC FUNCTION ODCIIndexUpdPartMetadata(
ia sys.ODCIIndexInfo,
palist sys.ODCIPartInfoList,
env sys.ODCIEnv)
RETURN NUMBER IS
BEGIN
RETURN ODCIConst.Success;
END ODCIIndexUpdPartMetadata;
STATIC FUNCTION ODCIIndexExchangePartition(
ia sys.ODCIIndexInfo,
ia1 sys.ODCIIndexInfo,
env sys.ODCIEnv)
RETURN NUMBER IS
BEGIN
RETURN ODCIConst.Success;
END ODCIIndexExchangePartition;
STATIC FUNCTION ODCIIndexInsert(
ia sys.ODCIIndexInfo,
ridlist sys.ODCIRidList,
newvallist sys.ODCINumberList,
env sys.ODCIEnv)
RETURN NUMBER IS
BEGIN
return ODCIConst.Success;
END;
STATIC FUNCTION ODCIIndexDelete(
ia SYS.ODCIIndexInfo,
rid VARCHAR2,
oldval number,
env SYS.ODCIEnv)
RETURN NUMBER IS
BEGIN
return ODCIConst.Success;
END;
STATIC FUNCTION ODCIIndexUpdate(
ia SYS.ODCIIndexInfo,
rid VARCHAR2,
oldval number,
newval number,
env SYS.ODCIEnv)
RETURN NUMBER AS
BEGIN
return ODCIConst.Success;
END;
STATIC FUNCTION ODCIIndexStart(
sctx IN OUT index_methods,
ia SYS.ODCIIndexInfo,
op SYS.ODCIPredInfo,
qi sys.ODCIQueryInfo,
strt number,
stop number,
cmpval number,
env SYS.ODCIEnv)
RETURN NUMBER AS
BEGIN
sctx := index_methods(1);
return ODCIConst.Success;
END;
MEMBER FUNCTION ODCIIndexFetch(
self IN OUT index_methods,
nrows NUMBER,
rids OUT SYS.ODCIridlist,
env SYS.ODCIEnv)
RETURN NUMBER AS
BEGIN
return ODCIConst.Success;
END;
MEMBER FUNCTION ODCIIndexClose(self IN index_methods, env SYS.ODCIEnv) RETURN NUMBER AS
BEGIN
return ODCIConst.Success;
END;
end;
Problem workaround:
--drop function test_eq_fun;
CREATE FUNCTION test_eq_fun(a number, b number) RETURN NUMBER AS
BEGIN
IF a = b then
RETURN 1;
ELSE
RETURN 0;
END IF;
END;
--drop operator test_eq;
CREATE OPERATOR test_eq
BINDING (number, number) RETURN NUMBER
USING test_eq_fun;
--drop indextype test_index_type;
CREATE INDEXTYPE test_index_type
FOR
test_eq(number, number)
USING index_methods
WITH ARRAY DML(number, sys.ODCINumberList)
WITH LOCAL RANGE PARTITION
WITH SYSTEM MANAGED STORAGE TABLES;
CREATE INDEXTYPE test_index_type
FOR
test_eq(number, number)
USING index_methods
WITH ARRAY DML
WITH LOCAL RANGE PARTITION
WITH SYSTEM MANAGED STORAGE TABLES;
--drop table test_table;
CREATE TABLE test_table (id NUMBER (19,0));
CREATE INDEX test_index ON test_table(id) INDEXTYPE IS test_index_type;
insert into test_table values (1);I get single for 1 row and batch for 2 or more rows in the following simplified simulation.
SCOTT@orcl12c> DESC SYS.ODCINUMBERLIST
SYS.ODCINUMBERLIST VARRAY(32767) OF NUMBER
SCOTT@orcl12c> CREATE OR REPLACE TYPE index_methods AS OBJECT
2 (
3 step number,
4 STATIC FUNCTION ODCIGetInterfaces(ifclist OUT SYS.ODCIObjectList) RETURN NUMBER,
5 STATIC FUNCTION ODCIIndexCreate (ia SYS.ODCIIndexInfo, parms VARCHAR2, env SYS.ODCIEnv) RETURN NUMBER,
6 STATIC FUNCTION ODCIIndexAlter (ia sys.ODCIIndexInfo, parms IN OUT VARCHAR2, altopt number, env sys.ODCIEnv) RETURN NUMBER,
7 STATIC FUNCTION ODCIIndexDrop(ia SYS.ODCIIndexInfo, env SYS.ODCIEnv) RETURN NUMBER,
8 STATIC FUNCTION ODCIIndexExchangePartition(ia SYS.ODCIIndexInfo, ia1 SYS.ODCIIndexInfo, env SYS.ODCIEnv) RETURN NUMBER,
9 STATIC FUNCTION ODCIIndexUpdPartMetadata(ia sys.ODCIIndexInfo, palist sys.ODCIPartInfoList, env sys.ODCIEnv) RETURN NUMBER,
10 STATIC FUNCTION ODCIIndexInsert(ia in sys.ODCIIndexInfo, rid in VARCHAR2, newval in NUMBER, env in SYS.ODCIEnv) RETURN NUMBER,
11 STATIC FUNCTION ODCIIndexInsert(ia in sys.ODCIIndexInfo, ridlist in sys.ODCIRidList, newvallist in your_type, env in SYS.ODCIEnv) RETURN NUMBER,
12 STATIC FUNCTION ODCIIndexDelete(ia SYS.ODCIIndexInfo, rid VARCHAR2, oldval number, env SYS.ODCIEnv) RETURN NUMBER,
13 STATIC FUNCTION ODCIIndexUpdate(ia SYS.ODCIIndexInfo, rid VARCHAR2, oldval number, newval number, env SYS.ODCIEnv) RETURN NUMBER,
14 STATIC FUNCTION ODCIIndexStart(sctx IN OUT index_methods, ia SYS.ODCIIndexInfo,
15 op SYS.ODCIPredInfo, qi sys.ODCIQueryInfo, strt number, stop number, cmpval number, env SYS.ODCIEnv) RETURN NUMBER,
16 MEMBER FUNCTION ODCIIndexFetch(self IN OUT index_methods, nrows NUMBER, rids OUT SYS.ODCIridlist, env SYS.ODCIEnv) RETURN NUMBER,
17 MEMBER FUNCTION ODCIIndexClose(self IN index_methods, env SYS.ODCIEnv) RETURN NUMBER
18 );
19 /
Type created.
SCOTT@orcl12c> CREATE OR REPLACE TYPE BODY index_methods IS
2 STATIC FUNCTION ODCIGetInterfaces(ifclist OUT sys.ODCIObjectList) RETURN NUMBER IS
3 BEGIN
4 ifclist := sys.ODCIObjectList(sys.ODCIObject('SYS','ODCIINDEX2'));
5 RETURN ODCIConst.Success;
6 END ODCIGetInterfaces;
7
8 STATIC FUNCTION ODCIIndexCreate (ia sys.ODCIIndexInfo, parms VARCHAR2, env sys.ODCIEnv) RETURN NUMBER IS
9 BEGIN
10 RETURN ODCIConst.Success;
11 END ODCIIndexCreate;
12
13 STATIC FUNCTION ODCIIndexDrop(ia sys.ODCIIndexInfo, env sys.ODCIEnv) RETURN NUMBER IS
14 BEGIN
15 RETURN ODCIConst.Success;
16 END ODCIIndexDrop;
17
18 STATIC FUNCTION ODCIIndexAlter (
19 ia sys.ODCIIndexInfo,
20 parms IN OUT VARCHAR2,
21 altopt NUMBER,
22 env sys.ODCIEnv)
23 RETURN NUMBER IS
24 BEGIN
25 RETURN ODCIConst.Success;
26 END ODCIIndexAlter;
27
28 STATIC FUNCTION ODCIIndexUpdPartMetadata(
29 ia sys.ODCIIndexInfo,
30 palist sys.ODCIPartInfoList,
31 env sys.ODCIEnv)
32 RETURN NUMBER IS
33 BEGIN
34 RETURN ODCIConst.Success;
35 END ODCIIndexUpdPartMetadata;
36
37 STATIC FUNCTION ODCIIndexExchangePartition(
38 ia sys.ODCIIndexInfo,
39 ia1 sys.ODCIIndexInfo,
40 env sys.ODCIEnv)
41 RETURN NUMBER IS
42 BEGIN
43 RETURN ODCIConst.Success;
44 END ODCIIndexExchangePartition;
45
46 STATIC FUNCTION ODCIIndexInsert(
47 ia sys.ODCIIndexInfo,
48 rid VARCHAR2,
49 newval NUMBER,
50 env sys.ODCIEnv)
51 RETURN NUMBER IS
52 BEGIN
53 dbms_output.put_line ('single');
54 return ODCIConst.Success;
55 END;
56
57 STATIC FUNCTION ODCIIndexInsert(
58 ia sys.ODCIIndexInfo,
59 ridlist sys.ODCIRidList,
60 newvallist your_type,
61 env sys.ODCIEnv)
62 RETURN NUMBER IS
63 BEGIN
64 dbms_output.put_line ('batch');
65 return ODCIConst.Success;
66 END;
67
68 STATIC FUNCTION ODCIIndexDelete(
69 ia SYS.ODCIIndexInfo,
70 rid VARCHAR2,
71 oldval number,
72 env SYS.ODCIEnv)
73 RETURN NUMBER IS
74 BEGIN
75 return ODCIConst.Success;
76 END;
77
78 STATIC FUNCTION ODCIIndexUpdate(
79 ia SYS.ODCIIndexInfo,
80 rid VARCHAR2,
81 oldval number,
82 newval number,
83 env SYS.ODCIEnv)
84 RETURN NUMBER AS
85 BEGIN
86 return ODCIConst.Success;
87 END;
88
89 STATIC FUNCTION ODCIIndexStart(
90 sctx IN OUT index_methods,
91 ia SYS.ODCIIndexInfo,
92 op SYS.ODCIPredInfo,
93 qi sys.ODCIQueryInfo,
94 strt number,
95 stop number,
96 cmpval number,
97 env SYS.ODCIEnv)
98 RETURN NUMBER AS
99 BEGIN
100 sctx := index_methods(1);
101 return ODCIConst.Success;
102 END;
103
104 MEMBER FUNCTION ODCIIndexFetch(
105 self IN OUT index_methods,
106 nrows NUMBER,
107 rids OUT SYS.ODCIridlist,
108 env SYS.ODCIEnv)
109 RETURN NUMBER AS
110 BEGIN
111 return ODCIConst.Success;
112 END;
113
114 MEMBER FUNCTION ODCIIndexClose(self IN index_methods, env SYS.ODCIEnv) RETURN NUMBER AS
115 BEGIN
116 return ODCIConst.Success;
117 END;
118 end;
119 /
Type body created.
SCOTT@orcl12c> CREATE FUNCTION test_eq_fun(a number, b number) RETURN NUMBER AS
2 BEGIN
3 IF a = b then
4 RETURN 1;
5 ELSE
6 RETURN 0;
7 END IF;
8 END;
9 /
Function created.
SCOTT@orcl12c> CREATE OPERATOR test_eq
2 BINDING (number, number) RETURN NUMBER
3 USING test_eq_fun
4 /
Operator created.
SCOTT@orcl12c> CREATE INDEXTYPE test_index_type
2 FOR
3 test_eq(number, number)
4 USING index_methods
5 WITH ARRAY DML(number, your_type)
6 WITH LOCAL RANGE PARTITION
7 WITH SYSTEM MANAGED STORAGE TABLES
8 /
Indextype created.
SCOTT@orcl12c> CREATE TABLE test_table (id NUMBER (19,0))
2 /
Table created.
SCOTT@orcl12c> CREATE INDEX test_index ON test_table(id) INDEXTYPE IS test_index_type
2 /
Index created.
SCOTT@orcl12c> insert into test_table values (1)
2 /
single
1 row created.
SCOTT@orcl12c> insert into test_table
2 select 2 from dual union all
3 select 3 from dual
4 /
batch
2 rows created.
SCOTT@orcl12c> insert into test_table select deptno from dept
2 /
batch
4 rows created.
SCOTT@orcl12c> insert into test_table select object_id from user_objects
2 /
batch
34 rows created.
SCOTT@orcl12c> -
Hi!
I have to write a program where you enter a name of a person and his points in a game using arrays. The program stops when you enter -99
Then the output should be like this
Person 1 45
Person 2 89
Person 30 X
We have just begun with arrays and i am not so good at it, i don't know what to enter in the brackets []. Can somebody help me? It has a lot of errors
Here is my program:
public class GradeArray {
public static void main(String args[]) {
String NameArray[] = new String [ 30 ];
String NumberString;
int NumberArray[] = new int [ 30 ];
int ControlExit = 0;
String output = "Name\t\tPoints\n";
while (ControlExit == 0) { // start while
NameArray[] = JOptionPane.showInputDialog(
null, "Enter the name of the person");
NumberString = JOptionPane.showInputDialog(
null, "Enter "+NameArray[]+"'s points(0-100) Enter -99 toExit");
NumberArray[] = Integer.parseInt(NumberString);
if (NumberArray[] == -99)
ControlExit = 1;
} // end while
for (int Control = 1; Control <= NumberArray.length; Control++)
output += NameArray[] + "\t\t" + NumberArray[] + "\n";
JTextArea outputArea = new JTextArea();
outputArea.setText( output );
JOptionPane.showMessageDialog(null,
outputArea);
System.exit( 0 );ok, i understand it better but my modified program has still errors
import javax.swing.*;
public class GradeArray2 {
public static void main(String args[]) {
String NameArray[] = new String [ 30 ];
String NumberString;
int Number;
int NumberArray[] = new int [ 30 ];
int ControlExit = 0;
String output = "Name\t\tGrade\n";
while (ControlExit == 0) { // start while
Name = JOptionPane.showInputDialog(
null, "Enter the name of the person");
Name = NameArray[Name];
NumberString = JOptionPane.showInputDialog(
null, "Enter "+NameArray+"'s points(0-100) Enter -99 to Exit");
Number = Integer.parseInt(NumberString);
NumberArray[Number] = Number;
if (NumberArray[Number] == -99)
ControlExit = 1;
} // end while
for (int Control = 1; Control <= NumberArray.length; Control++)
output += NameArray[Name] + "\t\t" + NumberArray[Number] + "\n";
JTextArea outputArea = new JTextArea();
outputArea.setText( output );
JOptionPane.showMessageDialog(null,
outputArea);
System.exit( 0 );
[\CODE] -
Hey guys, I'm a beginner programmer and I'm having a bit of a tough time with arrays. I could really use some help!
What I'm trying to do is roll one die and then record the rolls.
Here is my sample I/O:
How many times should I roll a die?
-> 8
rolling 8 times
2, 1, 5, 6, 2, 3, 6, 5
number of 1's: 1
number of 2's: 2
and so on....
Here is my incomplete code at this moment:
//CountDieFaces.java
import java.util.Scanner;
import java.io.*;
import library.Gamble;
public class CountDieFaces
//prompt for and read in: number of times user wants to roll one die
//simulate rolling a die that many times, counting how many times each face 1 thru 6 comes up
//print out: each roll
//AND the total number of times each face occured and the percentage of the time each face occured.
Scanner scan = new Scanner(System.in);
int[] faceCount= {0,0,0,0,0,0,0};
int dice;
System.out.println("How many times would you like to roll the die?");
int dieCount = scan.nextInt();
int dieRoll = Gamble.rollDie(); // Main calling class method
int count = 1;
while(count < dieCount)
System.out.println(faceCount[count]);
count++;
}Here is the gamble library:
//Gamble.java
package library;
public class Gamble
// returns 1, 2, 3, 4, 5, or 6
public static int rollDie()
int dieRoll = (int)(Math.random()*6)+1;
return dieRoll;
}and here are the errors I have so far:
----jGRASP exec: javac -g CountDieFaces.java
CountDieFaces.java:19: <identifier> expected
System.out.println("How many times would you like to roll the die?");
^
CountDieFaces.java:19: illegal start of type
System.out.println("How many times would you like to roll the die?");
^
CountDieFaces.java:25: illegal start of type
while(count < dieCount)
^
CountDieFaces.java:25: > expected
while(count < dieCount)
^
CountDieFaces.java:25: ')' expected
while(count < dieCount)
^
CountDieFaces.java:26: ';' expected
^
CountDieFaces.java:27: illegal start of type
System.out.println(faceCount[count]);
^
CountDieFaces.java:27: ';' expected
System.out.println(faceCount[count]);
^
CountDieFaces.java:27: invalid method declaration; return type required
System.out.println(faceCount[count]);
^
CountDieFaces.java:27: ']' expected
System.out.println(faceCount[count]);
^
CountDieFaces.java:27: ')' expected
System.out.println(faceCount[count]);
I'm really confused with how a the gamble library gets put into the array, so any help is appreciated! Also if anyone could explain the errors to me, I would really appreciate it.
thanks in advance,
wootens
Edited by: Wootens on Oct 18, 2010 8:55 PMD'oh!
Thanks you guys, fixed that. Although I'm having trouble with storing the die roll in the array. Any suggestions?
java.io.*;
public class CountDieFaces
//prompt for and read in: number of times user wants to roll one die
//simulate rolling a die that many times, counting how many times each face 1 thru 6 comes up
//print out: each roll
//AND the total number of times each face occured and the percentage of the time each face occured.
public static void main(String[] args)
Scanner scan = new Scanner(System.in);
int[] faceCount= {0,0,0,0,0,0};
int dice;
System.out.println("How many times would you like to roll the die?");
int dieCount = scan.nextInt();
int dieRoll = rollDie(); // Main calling class method
int count = 0;
while(count < dieCount)
System.out.println(faceCount[dieRoll]);
count++;
public static int rollDie()
int dieRoll = (int)(Math.random()*6)+1;
return dieRoll;
}Wootens -
ADF Mobile: WebService data control method call with array
JDev 11.1.2.3
ADF Mobile deployed to Android emulator
Hello All,
I am trying to invoke a method in my Web Service data control and get the following exception
Caused by: ERROR [oracle.adfmf.framework.exception.AdfInvocationRuntimeException] - Cannot serialize: [I@1dbae822
at oracle.adfmf.dc.ws.soap.SoapTransportLayer.invokeSoapRequest(Lorg/ksoap2/SoapEnvelope;)Ljava/lang/Object;(Unknown Source)
at oracle.adfmf.dc.ws.soap.SoapWebServiceOperation.invoke(Ljava/lang/String;Loracle/adfmf/dc/ws/soap/SoapGenericType;)Ljava/lang/Object;(Unknown Source)
at oracle.adfmf.dc.ws.soap.SoapWebServiceOperation.invoke(Ljava/lang/String;Ljava/util/Map;)Ljava/lang/Object;(Unknown Source)
at oracle.adfmf.dc.JavaBeanOperation.execute(Ljava/lang/Object;Ljava/util/Map;)Ljava/lang/Object;(Unknown Source)
at oracle.adfmf.dc.ws.WebServiceDataControlAdapter.invokeOperation(Ljava/util/Map;Loracle/adfmf/bindings/OperationBinding;)Z(Unknown Source)
at oracle.adfmf.bindings.dbf.AmxMethodActionBinding.execute()Ljava/lang/Object;(Unknown Source) This method is an AppModule method exposed as a service interface and the parameter for this method is a List<oracle.jbo.domain.Number>. The schema definition for the input is as follows:
<element name="acceptTask">
<complexType>
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="taskID" type="decimal"/>
</sequence>
</complexType>
</element>For the input to my binding, I have tried int[], Integer[] and List<Integer>. All of these result in similar errors.
I have also tried invoking this through a regular ADF application and that works fine with an int[]. It looks like something specific to the ADF Mobile SOAP layer.
Is this a bug or a restriction in the framework? Any workarounds that has worked for anyone?No luck. A WS DC method call with a simple parameter (java.lang.String or java.lang.Integer) works fine but I can't get it to work when there is an array input.
I have tried WS methods with int arrays and simple string arrays without any luck. All of them result in a cannot serialize error.
I can't figure out what I am doing wrong. Are there any working WS Datacontrol samples with array inputs? -
How to do like this with array?
How to do like this with array?
I have 2 constants array put in main while loop ( array1{6,6}; array2{4,4} ). Those arrays will be come the input data for st in the small while loop inside.
The input data look like : [6,6],[4,4],[6,6],[4,4]...... I have to put input data to result array[8]. The method is:
input data result data
[6,6] --------------------------------------------> [6,6,0,0,0,0,0,0]
[4,4] --------------------------------------------> [6,6,4,4,0,0,0,0] ( this period, just add each element in new array)
[6,6] --------------------------------------------> [6,6,4,4,6,6,0,0]
[4,4] --------------------------------------------> [6,6,4,4,6,6,4,4]
[6,6,4,4,6,6,4,4] ( 1st period )
When the las index of result data array is filled in, I have to collapse the result data array to be this array:
----------> collapse: [6,4,6,4,0,0,0,0] ( take the average of 2 continuous element add to new result data array)
Next input data
[6,6] --------------------------------------------> [6,4,6,4,6,0,0,0]
[4,4] --------------------------------------------> [6,4,6,4,6,4,0,0] ( this period, add the average of 2 continuous elements in new array )
[6,6] --------------------------------------------> [6,4,6,4,6,4,6,0]
[4,4] --------------------------------------------> [6,4,6,4,6,4,6,4]
[6,4,6,4,6,4,6,4] ( 2 nd period)
----------> 2nd collapse [5,5,5,5,0,0,0,0] ( take the average of 2 continous element add to new result data array)
Next input data
[6,6] ....wait until input data has 4 elements
[4,4] -------------------------------------------------------------------------------------> [5,5,5,5,5,0,0,0]
[6,6] ....wait until input data has 4 elements
[4,4] -------------------------------------------------------------------------------------> [5,5,5,5,5,5,0,0]
[6,6] ....wait until input data has 4 elements
[4,4] -------------------------------------------------------------------------------------> [5,5,5,5,5,5,5,0]
[6,6] ....wait until input data has 4 elements
[4,4] -------------------------------------------------------------------------------------> [5,5,5,5,5,5,5,5]
[5,5,5,5,5,5,5,5] ( third period )
----------> 3rd collapse [5,5,5,5,0,0,0,0]
This wayl to make the tren graph.I made an VI to do that , but it's not yet correct.
Attachments:
tryyyyyyy.vi 39 KB
trend_mode.JPG 49 KBFrankly, I don't understand your problem description or your VI.
In the description, the output array has a fixed size of 8 elements, is this correct? In this case you should initialize an array of 8 elements and do all operations "in place". I don't udnerstand the purpose of all the other code.
There are a lof of things that don't make any sense at all.
The second largest loop has no purpose, because it iterates only once per call
Sometimes you are concatenating an empty array to an existing array. This makes no difference.
Why is some of your data EXT representation???
What's up with complicated constructs such as that small loop shown in the picture. I show a somewhat simpler alternative.
Anyway, I have a hard time understanding your description. What should happen at the end? Do you have a link to a website that describes the algorithm? Does the algorithm have a name?
Message Edited by altenbach on 01-10-2008 09:55 AM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
Simplify.png 5 KB -
Problem is detected with Array : 01
I was backing up my server when it suddenly turned off. When it restarted it showed a critical error message saying "Problem is detected with Array : 01".
Windows tried starting and kept rebooting so I just turned it off.
When I launch the RAID utility I clearly see that the drive 02:01 seems ok but the other one is marked as "failed orisconnected" (it is connected ans spinning).
This is the spec: On the server I have windows 2012R2 installed on two HD 1TB on RAID1.
I habe an unused NAS, so I decided to create an iSCSI drive as a Target, and run the windows backup utility to do a Full Backup on it.hat may I have done wrong and how could I resolve this issue?
This clearly is related to the windows backup utility since this server was working fine until then.
Thanks.Hi,
The issue could be due to that one of the two drive is failed in the RAID 1. You need to replace the failed drive and rebuild the array automatically.
Best Regards,
Mandy
We
are trying to better understand customer views on social support experience, so your participation in this
interview project would be greatly appreciated if you have time.
Thanks for helping make community forums a great place. -
I Want to graph useing MSGraph with array data
Hi..
I need to skill to graph using the msgraph with array data
My forte version 2.0h
E-MAIL ADDRESS : [email protected]
TEL(C) : 02)273-3131(5233), 0331)40-8366(ÇöÀç ¿©±â ÀÖ½¿)
PAGER : 015-959-9390
HAND PHONE : 011-411-9395
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>This #pdfloc data is generated by RMSDK when user highlight (annotation) pdf and keep it in XML format in file system: E.g.
<annotation y="-116" isvisible="False" x="-110" width="220" height="100">
<dc:identifier>urn:uuid:DF061693-A668-49DF-A20B-DE243C463919</dc:identifier>
<dc:date>2015-03-02T12:04:53Z</dc:date>
<dc:creator>creator id</dc:creator>
<dc:title>Page 4, 02-Mar-2015 5:34 pm</dc:title>
<target>
<fragment start="#pdfloc(7f54,3,37,0,0,0,0,1)" end="#pdfloc(7f54,3,37,3,1,0,1,1)">
<text>by Matt</text>
</fragment>
</target>
<content>
<dc:date>2015-03-02T12:04:53Z</dc:date>
<text></text>
</content>
</annotation> -
Im a couple days new in java, Ive been searching for an answer for hours and havent found a solution.
This is the mistake it shows (when trying to use any element of the array):
array required, but java.util.ArrayList <java.lang.String> found
The array is:
public static ArrayList<String> numList = new ArrayList<String>();
Im filling it this way: (so that it contains each word of a file in separate)
BufferedReader br = new BufferedReader(new FileReader("Archivo.txt"));
try
while(true)
String aLine = br.readLine();
if(aLine == null) throw new EOFException("Le?do todo el archivo.");
if(!aLine.equals(""))
StringTokenizer st = new StringTokenizer(aLine);
while(st.hasMoreTokens())
numList.add(st.nextToken());
}catch(EOFException e)
The problem comes when I try to use the elements of the array (in specific when trying to convert each element of the array to int, so that i can do math operations with them).
for example:
for (a=0; w>a; a++)
int x = Integer.parseInt(numList[a])
Can anyone help me with this? (where is the mistake and how to convert from string array elements to int)
Thank you // Muchas GraciasThe trouble is that you're confusing ArrayLists with arrays. They're not the same thing.
Currently you're making an ArrayList. If you want an array of String, do this:
String[] myArray = new String[50];
int i = 0;
while(st.hasMoreTokens()) {
myArray[i] = st.nextToken();
i++;
}Or perhaps better yet:
String[] numListArray = numList.toArray(new String[0]);But you really don't need an array for what you're doing. Use an Iterator.
Iterator<String> strings = numList.iterator();
while(strings.hasNext()) {
int x = Integer.parseInt(strings.next());
}You get the idea. Read the Collections tutorial about iterators. Read the language spec about arrays. Also look at the java.util.Arrays class. -
Recursive WITH (Recursive Subquery Factoring) Never Returns
11.2.0.2 database on Windows, SQL Developer Version 3.2.20.09, build MAIN-09.87 (Database and SQL Developer are on the same machine. I have also tried connecting to a Linux 11.2 database and have the same results.)
I've been doing some simple testing with recursive WITH (Recursive Subquery Factoring) and when I run this following statement in SQL*Plus it returns instantly. However when running in SQL Developer it never returns, I've let it run for quite a long time (172 seconds) and gotten nothing, I finally kill the statement. Once I ran it and even killing the job didn't come back. I can get an explain plan but if I try to run it, run as script or autotrace it never returns. I have only one plan in the plan_table for this test, and it's only 4 lines long. No errors, no messages.
WITH get_plan (query_plan, id, planlevel) as
select ' '||operation||' '||options||' '||object_name query_plan, id, 1 planlevel
from plan_table
where id = 0
union all
select lpad(' ',2*planlevel)||p.operation||' '||p.options||' '||p.object_name query_plan, p.id, planlevel+1
from get_plan g, plan_table p
where g.id = p.parent_id
SELECT QUERY_PLAN FROM GET_PLAN ORDER BY PLANLEVEL;Hi Jeff, using either give the same results. The query is "running", as is the little graphic with the bouncing gray bar is moving back and forth saying either "Query Results" or "Scriptrunner Task" as appropriate.
OK this is odd. I run a count(*) on plan_table in SQL*Plus and get 4, in SQL Developer I get 487. Hun? That makes no sense I'm connect as the same user in each. Where are all these other entries coming from and why can't I see them in SQL Plus? Does SQL Developer have it's own PLAN_TABLE?
**EDIT --- Yes that seems to be the case. The PLAN_ID I see in SQL Plus doesn't even exist in the SQL Deveropler version of the table. OK that's good to know. I assume the plan_table for SQL Developer is local to it somehow? It's not in the database as best I can see.
Edited by: Ric Van Dyke on Feb 7, 2013 5:19 PM -
To use "analytic function" at "recursive with clause"
http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_10002.htm#i2077142
The recursive member cannot contain any of the following elements:
・An aggregate function. However, analytic functions are permitted in the select list.
OK I will use analytic function at The recursive member :-)
SQL> select * from v$version;
BANNER
Oracle Database 11g Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL> with rec(Val,TotalRecCnt) as(
2 select 1,1 from dual
3 union all
4 select Val+1,count(*) over()
5 from rec
6 where Val+1 <= 5)
7 select * from rec;
select * from rec
ERROR at line 7:
ORA-32486: unsupported operation in recursive branch of recursive WITH clauseWhy ORA-32486 happen ?:|Hi Aketi,
It works in 11.2.0.2, so it is probably a bug:
select * from v$version
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for IBM/AIX RISC System/6000: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
with rec(Val,TotalRecCnt) as(
select 1,1 from dual
union all
select Val+1,count(*) over()
from rec
where Val+1 <= 5)
select * from rec
VAL TOTALRECCNT
1 1
2 1
3 1
4 1
5 1 Regards,
Bob -
Let us discussion "non recursive with clause" usage
I think there are 3 "non recursive with clause" usage.
My question is do you know more "non recursive with clause" usage ?Another option is to use it to materialize remote data on the fly. Especially in combination with the materialize hint.
I think I used this tecnique once, but can't find the proper example anymore. Very simplified it could looked like this:
with fetchData as (Select /*+materialize */ * from myremoteTable@databaselink where status = 'CURRENT')
select *
from fetchdata r
full outer join localData l on r.id = r.id
where l.status = 'CURRENT'
;From 11g onwards: use the with clause to create better column names in larger select from dual combinations.
Not sure with that results in a suitable use case.
So instead of
with orders as
(select 1 id , 173 order#, 'John' customer, 'America' region from dual union all
select 2 id , 170 order#, 'Paul' customer, 'UK' region from dual union all
select 3 id , 240 order#, 'Hans' customer, 'Europe' region from dual union all
select 4 id , 241 order#, 'Francois' customer, 'Europe' region from dual )
select * from orders;you can now write
with
orders (id, order#, customer,region) as
(select 1 , 173 , 'John' , 'America' from dual union all
select 2 , 170 , 'Paul' , 'UK' from dual union all
select 3 , 240 , 'Hans' , 'Europe' from dual union all
select 4 , 241 , 'Francois' , 'Europe' from dual )
select * from orders;THis makes it a little easier to create tase data useing some excel sheet I guess.
Maybe you are looking for
-
LSMW LOGICAL PATH not set error
Hi, when i save an lsmw the error is coming as logical path not set. I guess this is for the CONV and READ files. Can ne one tell where can we speicfy this path. Right now we have to manually store the paths for these. Where in the settings can w
-
So, I made a backup of my device (iPad 2). It was on iOS 4.3.2. I updated to iOS 7. Now, I'm at the default opening screen. I have to choose language, country, then connect to WiFi. After that, it asks me if I want to start new or restore from a back
-
Default costing lot size and price unit as 100 in material master
Hello, The costing lot size and price unit is "1" by default in material master. Due to this in CK11N the costing lot size is coming as 1. Then we go to MM02 and change the master by making costing lot size as 100 and price unit as 100. Please advise
-
Umm... can you tell me how to take songs from my ipod and put them onto my computer? i thought this would be easy but i cant figure it out.. ive tried click and draging the songs to the itune library and to my music folder but that doesent work.. so
-
Collor is different after printing
Hello, I created a logo where I use the color "Pantone Process DS Cyan C". On the screen it seems Cyan. When I print it it seems more blue than Cyan. I then printed a test page to check in ink levels: Magenta, Cyan, Yellow and Black. In the test page