1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
san4es73 [151]
3 years ago
10

Consider an array inarr containing atleast two non-zero unique positive integers. Identify and print, outnum, the number of uniq

ue pairs that can be identified from inarr such that the two integers in the pair when concatenated, results in a palindrome. If no such pairs can be identified, print -1.Input format:Read the array inarr with the elements separated by ,Read the input from the standard input streamOutput format;Print outnum or -1 accordinglyPrint the output to the standard output stream
Computers and Technology
1 answer:
Delvig [45]3 years ago
3 0

Answer:

Program.java  

import java.util.Scanner;  

public class Program {  

   public static boolean isPalindrome(String str){

       int start = 0, end = str.length()-1;

       while (start < end){

           if(str.charAt(start) != str.charAt(end)){

               return false;

           }

           start++;

           end--;

       }

       return true;

   }  

   public static int countPalindromePairs(String[] inarr){

       int count = 0;

       for(int i=0; i<inarr.length; i++){

           for(int j=i+1; j<inarr.length; j++){

               StringBuilder sb = new StringBuilder();

               sb.append(inarr[i]).append(inarr[j]);

               if(isPalindrome(sb.toString())){

                   count++;

               }

           }

       }

       return count == 0 ? -1 : count;

   }

   public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);

       String line = sc.next();

       String[] inarr = line.split(",");

       int count = countPalindromePairs(inarr);

       System.out.println("RESULT: "+count);

   }

}

Explanation:

OUTPUT:

You might be interested in
Assume that the variable myString refers to a string. Write a code segment that uses a loop to print the characters of the strin
Svetach [21]

Answer:

hi my name is antonette Jane S pascua please help me my question thank you for your answer

5 0
3 years ago
the graph at left in the tctct, c-plane models the global wind power capacity, ccc, in gigawatts, ttt years since 199619961996.
Elena-2011 [213]

The intercept of a graph is the point where the graph crosses the axes of the graph.

The interpretation of the c-intercept is: <em>in 1996, the global wind power capacity was approximately 7 gigawatts.</em>

On the graph (see attachment), we have the following observations

  1. The vertical axis represents the global wind power capacity (i.e. the c-axis)
  2. The horizontal axis represents the years since 1996 (i.e. the t-axis)

So, the c-intercept is the point that crosses the vertical axis.

From the graph, the curve crosses the c-axis at c = 7, and t = 0 (i.e. years = 1996)

Hence, the interpretation of the c-intercept is: <em>in 1996, the global wind power capacity was approximately 7 gigawatts.</em>

<em />

<em />

Read more about intercepts at:

brainly.com/question/3334417

4 0
2 years ago
Assume the number variable contains the number 1000.
Inga [223]

Answer:

Explanation:

We could get the four options for this particular example, but we must know what happens with the variable number the value 1000.

In this case, we are going to assume four scenarios:

1) n = n - n this is equal to 0

2) n = (n - n) + n = 1000

3) n = n * 2 = 2000

4) n = n * 3 = 3000

These are simple examples, we could get these options in different ways.

5 0
3 years ago
Write a loop to print 10 to 90 inclusive (this means it should include both the
Semmy [17]

Answer:

The loop in cpp language is as follows.

for(int n=10; n<=90; n++)

{

cout<<n<<" ";

count = count+1;

if(count==10)

{

cout<<""<<endl;

count=0;

}

}

Explanation:

1. The expected output is obtained using for loop.

2. The loop variable, n is initialized to the starting value of 10.

3. The variable n is incremented by 1 at a time, until n reaches the final value of 90.

4. Every value of n beginning from 10 is displayed folllowed by a space.

5. When 10 numbers are printed, a new line is inserted so that every line shows only 10 numbers.

6. This is achieved by using an integer variable, count.

7. The variable count is initialized to 0.

8. After every number is displayed, count is incremented by 1.

9. When the value of count reaches 10, a new line is inserted and the variable count is initialized to 0 again. This is done inside if statement.

10. The program using the above loop is shown below along with the output.

PROGRAM

#include <stdio.h>

#include <iostream>

using namespace std;

int main()

{

   int count=0;

   for(int n=10; n<=90; n++)

   {

       cout<<n<<" ";

       count = count+1;

       if(count==10)

       {

           cout<<""<<endl;

           count=0;

       }

       

   }

   return 0;

}  

OUTPUT

10 11 12 13 14 15 16 17 18 19  

20 21 22 23 24 25 26 27 28 29  

30 31 32 33 34 35 36 37 38 39  

40 41 42 43 44 45 46 47 48 49  

50 51 52 53 54 55 56 57 58 59  

60 61 62 63 64 65 66 67 68 69  

70 71 72 73 74 75 76 77 78 79  

80 81 82 83 84 85 86 87 88 89  

90

1. In the above program, the variable count is initialized inside main() but outside for loop.

2. The program ends with a return statement since main() has return type of integer.

3. In cpp language, use of class is not mandatory.

8 0
4 years ago
Compare the two types of formatting that IDE devices must go through. What is the primary difference between the two?
Andrei [34K]
A quick format<span> changes the file system while the </span>full format<span> also checks the </span>drive for bad sectors.  <span>The scan for bad sectors is the reason why the Full </span>format<span> takes twice as long as the </span>Quick format<span>. If you choose the </span>Quick format<span> option, the </span>format<span> removes address files from the partition, but does not scan the disk for bad sectors.</span>
7 0
3 years ago
Read 2 more answers
Other questions:
  • Which description best describes how mass spectroscopy is useful in the field of forensic toxicology
    6·1 answer
  • The content of a text is its
    8·1 answer
  • Which of the following grinding methods is best suited to a shorter cylindrical workpiece?
    8·1 answer
  • Amelia has selected the chart in her PowerPoint and needs to change the chart type. Which one of the Chart Tools tabs would she
    15·1 answer
  • The _____ is the button that you push to take a photograph. i think its B Help PLZ
    5·1 answer
  • PLS HELP IMEDIATELY!!!!!
    15·2 answers
  • Would a sim card(activated) be able to function on any phone regardless of the companies carrier?
    7·1 answer
  • Have you ever tried to learn a new language or do you have friends who've had that experience? What are some of the steps you wo
    10·2 answers
  • Based on the following quote from Leonardo Da Vinci, what would be his definition of a fine artist? “Principles for the Developm
    11·2 answers
  • What is the full form of SAARC<br><br>And free point!! ​
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!