A Plus B
Tudor is sitting in math class, on his laptop. Clearly, he is not paying attention in this situation. However, he gets called on by his math teacher to do some problems. Since his math teacher did not expect much from Tudor, he only needs to do some simple addition problems. However, simple for you and I may not be simple for Tudor, so please help him!
Input
The first line will contain an integer (
), the number of addition problems Tudor needs to do. The next
lines will each contain two space-separated integers whose absolute value is less than
, the two integers Tudor needs to add.
Output
Output lines of one integer each, the solutions to the addition problems in order.
Sample Input
2
1 1
-1 0
Sample Output
2
-1
Comments
include<iostream>
using namespace std;
int main(){int a,x,y; cin>>a;
for(int i=1;i<=a;i++){ cin>>x>>y; cout<<x+y<<endl;} return 0;}
include<iostream>
using namespace std; int main(){
Porque me da error
int n,x,a,b; cin>>n; cout<<"\n"; if(n<=100000){ for(int i=1;i<=n;i++){
Solo tienes que leer dos números de input y sumarlos, no tienes que recorrer ningún rango, además, nunca uses debug en lo que mandes al dmoj, en el caso de prueba se verifica que la salida del programa sea exactamente la esperada, no una con información innecesaria
PD: no tienes que imprimir un salto de linea después de leer la información
include<iostream>
using namespace std; int main() { int a,b,c,d, e = 0; cin>>a>>b>>c>>d; e = ((a+b)+1)/(d*c); cout << "Resultado: "<<e; return 0;
} que puedo hacer basandome en esto ?
J
.
Por ejemplo, en vez de escribir cout<<"Hola"<<endl;
puedes escribir cout<<"Hola\n";
o cout<<"Hola"<<"\n";
Ahmed05 trata de no utilizar <<endl, eso puede ponerlo más lento, mejor utiliza \n o si no utiliza las funciones scanf y printf de la librería stdio.h