목록분류 전체보기 (264)
BASHA TECH
Task Given n names and phone numbers, assemble a phone book that maps friends' names to their respective phone numbers. You will then be given an unknown number of names to query your phone book for. For each queried, print the associated entry from your phone book on a new line in the form name=phoneNumber; if an entry for name is not found, print Not found instead. Note: Your phone book should..
Task Given an array, A, of N integers, print A's elements in reverse order as a single line of space-separated numbers. Example A = [1, 2, 3, 4] Print 4 3 2 1. Each integer is separated by one space. Input Format The first line contains an integer, N (the size of our array). The second line contains N space-separated integers that describe array A's elements. Constraints Constraints 1
Task Given a string, S, of length N that is indexed from 0 to N - 1, print its even-indexed and odd-indexed characters as 2 space-separated strings on a single line (see the Sample below for more detail). Note: 0 is considered to be an even index. Example s = abdecf Print abc def Input Format The first line contains an integer, T (the number of test cases). Each line i of the T subsequent lines ..
Task Given an integer, n, print its first 10 multiples. Each multiple n x i (where 1
Task Write a Person class with an instance variable, age, and a constructor that takes an integer, initailAge, as a parameter. The constructor must assign to after confirming the argument passed as is not negative; if a negative argument is passed as initialAge, the constructor should set age to 0 and print Age is not valid, setting age to 0.. In addition, you must write the following instance m..
Task Given an integer, n, perform the following conditional actions: If n is odd, print Weird If n is even and in the inclusive range of 2 to 5, print Not Weird If n is even and in the inclusive range of 6 to 20, print Weird If n is even and greater than 20, print Not Weird Complete the stub code provided in your editor to print whether or not n is weird. Input Format A single line containing a ..
Task Given the meal price (base cost of a meal), tip percent (the percentage of the meal price being added as tip), and tax percent (the percentage of the meal price being added as tax) for a meal, find and print the meal's total cost. Round the result to the nearest integer. Example mealCost = 100 tipPercent = 15 taxPercent = 8 A tip of 15% * 100 = 15, and the taxes are 8% * 100 = 8. Print the ..
Task Complete the code in the editor below. The variables , , and are already declared and initialized for you. You must: Declare 3 variables: one of type int, one of type double, and one of type String. Read 3 lines of input from stdin (according to the sequence given in the Input Format section below) and initialize your 3 variables. Use the operator to perform the following operations: Print ..
Task Complete the function displayPathtoPrincess which takes in two parameters - the integer N and the character array grid. The grid will be formatted exactly as you see it in the input, so for the sample input the princess is at grid[2][0]. The function shall output moves (LEFT, RIGHT, UP or DOWN) on consecutive lines to rescue/reach the princess. The goal is to reach the princess in as few mo..
This week we started with the simplest linear data structure: arrays. Arrays are collections of elements of the same type, either primitive data types or objects of class types. Arrays have an attribute length, which helps us traverse arrays with for/while loops. Nevertheless, arrays have an important limitation: once the capacity is set it cannot be modified. Therefore, we cannot store in array..