Advertisement
fryc1906

DynamicArray1

Apr 20th, 2016
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main(){
  5. int x;
  6. do{
  7.     cout<<"Wprowadz liczbe naturalna od 1 do 25";
  8.     cin>>x;
  9.     if(x>25||x<1){
  10.         cout<<"Blad! Podales zla liczbe";
  11.     }
  12. }while(x>25||x<1);
  13.  
  14. int *tab = new int[x];
  15.  
  16. for(int i=0;i<x;i++){
  17.     cout<<"Podaj "<<i+1<<" liczbe"<<endl;
  18.     cin>>tab[i];
  19.  
  20. }
  21. for(int i=0;i<x;i++){
  22.     if(i%2==0&&i<0){
  23.         tab[i]*=-1;
  24.     }
  25.     if((i%2==1)&&i>0){
  26.         tab[i]*=-1;
  27.     }
  28. }
  29.  
  30. for(int i=0;i<x;i++){
  31.     cout<<tab[i]<<endl;
  32. }
  33.  
  34.  
  35.     return EXIT_SUCCESS;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement