Posts by Leko • 337 points
15 posts
-
5
votes1
answer806
viewsQ: Error: Object of type 'closure' is not subsettable
I’m trying to encapsulate a code in functions but in the process such error happens: Object of type 'closure' is not subsettable But I can’t find why. Follow the code working: h = (b-a)/n B =…
-
3
votes2
answers1732
views -
3
votes1
answer5807
viewsQ: Percentage in Java
Business rule: A program that receives the code of a user, the Qtd in Kwh q he consumes and the type of it that can be 3: each type multiplies the cost of energy consumed as the constants are…
-
-1
votes1
answer239
viewsQ: Function that reverses the values of the vector into another vector
I have the following code: import java.util.Scanner; public class ativ15 { public static void main (String[] args) { Scanner sc = new Scanner (System.in); int i; int A[] = new int [10]; int B[] =…
-
0
votes1
answer4794
viewsQ: Error: error: class, interface, or Enum expected
Why is my code making the mistake: error: class, interface, or Enum expected Follows the code: import java.util.Scanner; public class teste175 { public static void main (String[] args) { Scanner sc…
-
0
votes3
answers208
viewsQ: Repetition of elements
I’m having difficulty generating as output the amount of elements repeated in the vector. Follow the code: #include <stdio.h> #include<stdlib.h> int main() { int N, i, temp, repetidos =…
-
1
votes2
answers74
viewsQ: Vector that generates elements
I would like to generate a vector where your next position element is added to 1. For example: be a vetor[3], would like that v[0] = 1 and v[1] = v[0] + 1, v[2] = v[1] + 1 and so on. How would you…
-
0
votes1
answer787
viewsQ: Input values into the matrix
I have the following code that reads a 10x10 matrix: public class t151 { static final int n = 10; public static void main (String[] args){ int A[][] = new int [n][n]; int i,j; for (i=0; i < n;…
-
0
votes1
answer211
viewsQ: Arrayindexoutofboundsexception error while executing code
My code is giving the following error: Exception in thread "main" java.lang.Arrayindexoutofboundsexception: 10 at t151.main(t151.java:19) What it means and how to fix? Follows the code: public class…
-
1
votes1
answer118
viewsQ: Increment in Java vectors
I am having doubts about some lines of a code, I will put them in the form of a comment. Follows: import java.util.Scanner; public class Teste131 { static final int max = 100000; public static void…
-
1
votes1
answer175
viewsQ: What is the increment on a pointer for?
Datum: #include <stdio.h> int main () { int x = 1; x++; int *y = &x; y = y + 1; printf("%d\n",x ); } The exit is 2. In that case I would like to know if the following interpretation is…
-
0
votes2
answers2623
viewsQ: Square Root in C
Follows the code: #include <stdio.h> #include <math.h> int main() { double distancia; double x1, y1, x2, y2; scanf("%lf %lf ", &x1, &y1); scanf("%lf %lf ", &x2, &y2);…
-
2
votes1
answer2214
viewsQ: Percentage in C
Given the following statement: Write an algorithm to show on the screen if each N number, typed user is even or odd. The algorithm should also show on the screen the sum of all even numbers, the sum…
-
1
votes2
answers285
viewsQ: Where to use accumulators in a unique peer-review algorithm?
Where should I fit the accumulators of this code I have written for now? #include <stdio.h> int main() { int N; int somapar; int somaimpar; do{ printf("\n Digite um número qualquer: ");…
-
0
votes2
answers105
viewsQ: Parameters, functions in C
I am a beginner in programming and I have a lot of doubt about the functions and the parameters. Follow a code example: #include math.h int main(int argc, char *argv[]) // Dúvida nessa linha {…