First Timus Problem (1000) C, C++, C#, Python

Bytelog

I just noticed that I haven’t put the solution to the first problem anywhere in here, and just for the record…
Problem: Make a program that takes as input integers ‘a’ and ‘b’. The output must be a+b.
C:


#include <stdio.h>
int main()
{
   int a, b;
   scanf("%d%d", &a, &b);
   printf("%dn", a + b);
   return 0;
}

C++:


#include <iostream>

using namespace std;

int main()
{
       int a,b;
       cin >> a >> b;
       cout << a+b;
       return 0;
}

or…


#include <iostream>

int main()
{
       int a,b;
       std::cin >> a >> b;
       std::cout << a+b << std::endl;
       return 0;
}

C#:


using System;

public class Sum
{
    private static void Main()
    {
        string[] ans = Console.ReadLine().Split(' ');
        Console.WriteLine(int.Parse(ans[0]) + int.Parse(ans[1]));
    }
}

Python:


print(sum(int(a) for a in input().split(' ')))

View original post

Advertisements

ضع تعليقك هنا

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: