İki ədədin cəmi#518

İki ədədin cəmi (Həll təhlili)

Read the number of test cases . Process the test cases sequentially: read a pair of numbers and print their sum.

Algorithm implementation

Read the number of test cases .

scanf("%d",&t);

Process test cases sequentially.

while(t--)
{

Read the numbers and and print their sum on a separate line.

  scanf("%d %d",&a,&b);
  printf("%d\n",a + b);
}

Algorithm implementation — for loop

Read the number of test cases .

scanf("%d",&t);

Process test cases sequentially.

for(i = 0; i < t; i++)
{

Read the numbers and and print their sum on a separate line.

  scanf("%d %d",&a,&b);
  printf("%d\n",a + b);
}

Java implementation

import java.util.*;

public class Main
{
  public static void main(String []args)
  {
    Scanner con = new Scanner(System.in);
    int t = con.nextInt();
    while (t-- > 0)
    {
      int a = con.nextInt();
      int b = con.nextInt();
      System.out.println(a + b);      
    }
    con.close();
  }
} 

Python implementation

Read the number of test cases .

tests = int(input())

Process test cases sequentially.

for i in range(tests):

Read the numbers and and print their sum on a separate line.

  a, b = map(int,input().split())
  print(a + b)