|
|
#include <iostream> using namespace std; int main() { int a=1, b=5, sum=0; sum=a+b; cout<<sum<<endl; return 0; } Ты вводишь два числа, а не определяешь в коде. А система проверки может дать тебе любые два числа, не обязательно a=1 и b=5 ты должен ввести входные данные выводные данные a = input() b = input() a = int(a) b = int(b) c = a+b print c
this should be correct isn't it ? It is correct in Python 2, though explicit cast is excessive. In Python 3, use should add brackets after 'print'. import java.util.Scanner; public class Summa { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan=new Scanner( System.in); System.out.println("Введите значение a"); int a; a=scan.nextInt(); System.out.println("Введите значение b"); int b; b=scan.nextInt(); System.out.println(" a + b = " + (a + b)); } } You program outputs: Введите значение a Введите значение b a + b = 6 istead of just 6 Edited by author 03.10.2014 11:2031 байт ни кто короче уже не сделает //********************************************* //FreePascal 2.0.4 var a,b,u:longint; begin readln(a,b); for u:=1 to b do inc(a); writeln(a); end. //********************************************* //Visual C# 2010 using System; public class Sum { private static void Main() { string[] tokens = Console.ReadLine().Split(' '); Console.WriteLine(int.Parse(tokens[0]) + int.Parse(tokens[1])); } } //********************************************* //Java 1.7 import java.util.Scanner; public class test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println(sc.nextInt() + sc.nextInt()); } } #include<iostream> using namespace std ; int main() { int a, b ; cout<<"Plz enter two numbers: "<<'\n' ; cin>> a >> b ; cout<<"Here is your output: "<< a + b <<'\n' ; return 0 ; } what's the wrong!!! I've written this code in c++ and submitted under visual c++2010 but they don't accept it..why????? Because you write some text in output. Remove all text. #include<iostream> using namespace std ; int main() { int a, b ; cin>> a >> b ; cout<< a + b ; return 0 ; } Like this thanks for your answer :) using System; public class Sum { private static void Main() { string[] tokens = Console.ReadLine().Split(' '); Console.WriteLine(int.Parse(tokens[0]) + int.Parse(tokens[1])); } } import java.util.Scanner; public class firstexercise{ public static void main(String[]args){ Scanner scanner=new Scanner(System.in); int c=0; System.out.println("Введите первое число."); int a=scanner.nextInt(); System.out.println("Введите второе число."); int b=scanner.nextInt(); c=a+b; System.out.println("Ответ = " + c); } } There should be no prompt message and output only answer: import java.util.Scanner; public class firstexercise{ public static void main(String[]args){ Scanner scanner=new Scanner(System.in); int c=0; int a=scanner.nextInt(); int b=scanner.nextInt(); c=a+b; System.out.println(c); } } #include<iostream> using namespace std; int main() { int a,b; cin>>a>>b; cout<<a+b; return 0; } after int main() need "{" #include <fstream> using namespace std; int main() { ifstream fin("INPUT.TXT"); ofstream fout("OUTPUT.TXT"); int a,b; fin >> a >> b; fout << a + b; fin.close(); fout.close(); } поидет ?? Мен агылшынша тiлде белмимын!! How to respond to the tasks in your site? a file or command line? tell me if the command line .. Read FAQ Кай жерде ' read' ? Корсетше мағам .. namespace Project1 { class Programa { static void Main() { Console.Write("Введите первое число: "); int First = Convert.ToInt32(Console.ReadLine()); Console.Write("Введите второе число: "); int Second = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Сумма числа {0} и числа {1} равна {2}", First, Second, (First + Second)); Console.ReadKey(); } } } Edited by author 18.01.2013 23:09 Edited by author 18.01.2013 23:09 or namespace Project2 { class adsf { static void Main() {
int x; int y;
x = Convert.ToInt32(Console.ReadLine()); y = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Сумма числел = " + (x+y));
Console.ReadKey(); } } } #include <iostream> int main() { using namespace std; int a, b, buffer; cin>>a>>b; int *mass=new int[b]; int *deep=new int[33180]; for (int i4=0; i4<b; i4++) { mass[i4]=0; deep[i4]=1200; } for (int i5=b; i5<33180; i5++) { deep[i5]=a; } for (int i6=0; i6<33180; i6++) { for (int i9=1; i9<33180; i9++) { if (deep[i9-1]>deep[i9]) { buffer=deep[i9-1]; deep[i9-1]=deep[i9]; deep[i9]=buffer; } } } mass[0]=a; mass[b-1]=b; for (int i=0; i<b; i++) { for (int i2=1; i2<b; i2++) { if (mass[i2-1]>mass[i2]) { buffer=mass[i2-1]; mass[i2-1]=mass[i2]; mass[i2]=buffer; } } } int sum=0; for (int i3=0; i3<b; i3++) { sum+=mass[i3]; } cout<<sum; delete []deep; delete []mass; return 0; } This solution works 1 second and output 1 if a=1 or b=1, and get AC! ab = raw_input() print int(ab[0]) + int(ab[2]) package timus; class timus {
public static void main (String args[]) { int a = 1,b = 5; System.out.println(a+b); } } Edited by author 20.01.2014 23:38 Edited by author 20.01.2014 23:38 var a,b,u:longint; begin readln(a,b); for u:=1 to b do inc(a); writeln(a); end. AC 0.015s 86k var a,b:integer; begin readln(a,b); writeln(a mod 10 + a div 10 * 10 + b mod 10 + b div 10 * 10); readln; end. Hello Edited by author 09.07.2013 15:24 Edited by author 09.07.2013 17:20 С хера он не принимает задачу?! Вот: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Dimmell { class Program { static void Main(string[] args) { int a = Convert.ToInt32(Console.ReadLine()); int b = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(a + b); } } } Edited by author 03.06.2013 19:24 sum=0 a= ((int (i) for i in input().split(' '))) for j in a: sum+=j print (sum) Edited by author 30.04.2013 11:24 Edited by author 30.04.2013 11:25 I'm only start to learn Haskell. I'm confused with std function and IO. My solution (does not work): main = do a <- getLine let b = sum map read words a // <- I try to use this functions putStrLn (show b) let b = words a // work, but let b = sum map (read::Int) words a //does not work Where I wrong? |
|
|