- import jaa.util.Scanner;
- public class LoopAlgorithm {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int t = in.nextInt();
- for (int i = 0; i < t; i++) {
- int a = in.nextInt();
- int b = in.nextInt();
- int n = in.nextInt();
- int result = 0;
- for (int j = 0; j < n; j++) {
- if (j == 0) {
- result = (result +a + (int) (Math.pow(2, j) * b));
- } else {
- result = (int) Math.pow(2, j) * b;
- System.out.println(result+" ");
- }
- }
- System.out.print("");
- }
- in.close();
- }
- }
Tuesday, April 23, 2019
Java Loop
Subscribe to:
Post Comments (Atom)
Blueprint for self-improvement
To learn faster: Make the process fun To understand yourself : Write To understand the world better : Read To build deeper connection : Lis...
-
Problem statement: There is a colony of 8 cells arranged in a straight line where each day every cell competes with its adjacent cells(neig...
-
Problem statement: Given an array of positive or negative integer. How will you write an algorithm to find out the largest element in the ...
-
Problem statement: Write a function to print spiral order traversal of a tree. For example. Input - 10 J H I A C D F E B G...


No comments:
Post a Comment