Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main(){
- float nf;
- cin>>nf; // no modifique la instrucción de lectura
- // Case 1
- if(nf<0 or nf != int(nf)){
- cout<<"Error, el número ingresado debe ser entero y positivo";
- }
- // Case 2
- else{
- int acumulador = 0;
- for(int i=1 ; i<=nf ; i++){
- acumulador += i;
- }
- cout<<acumulador;
- }
- return 0; // no utilize system(pause)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement