online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <iostream> int* swap (int*a, int* b ){ int temp = *a; *a=*b; *b=temp; return b; } void settable(int t[],size_t size,int * ptr){ int* ptrcopy=ptr; for (size_t i=0; i<size;/*i++,ptrcopy++*/) t[i++]=*ptrcopy++; return; } using namespace std; int main() { int tab[]={3,4,2,7,2,9}; size_t rozmiar = sizeof(tab)/sizeof(tab[0]); // cout<<"rozmiar="<<rozmiar<<endl; int *a=tab; // wskaźnik na początek int *b=tab+rozmiar-1; // wskaźnik na koniec int c=10; // zabezpieczenie przed niekończącą się pętlą // zamiast liczyć ilość przestawianie wartości // i na tej podstawie rozmiary tablic // lub realloc, ale bez malloc i free to jakoś dziwnie, while (a<b and c--){ if(*b%2!=0 and *a%2==0) {swap(a,b);} if(*b%2==0){b--;cout<<"*b="<<*b<<endl;} if(*a%2!=0){a++;cout<<"*a="<<*a<<endl;} } cout<<"1.(b==a)="<<(b==a)<<endl; b++; cout<<"2.(b==a)="<<(b==a)<<endl; a=tab; // przestawienie "a" z powrotem na początek tablicy // obliczenie rozmiarów tablic arytmetyka wskaźników size_t oddrozmiar=b-tab; size_t evenrozmiar=rozmiar-(b-tab); cout<<"b-tab="<<oddrozmiar<<endl; cout<<"rozmiar-(b-tab)="<<evenrozmiar<<endl; // rezerwowanie nowych tablic int odd[oddrozmiar]; int even[evenrozmiar]; // przekopiowanie wartości settable(odd,oddrozmiar,a); settable(even,evenrozmiar,b); // wyświetlenie tablic; for (auto c :tab) cout<<c<<", "; cout<<endl; cout<<"Nieparzyste: "; for (auto c :odd) cout<<c<<", "; cout<<endl; cout<<"Parzyste: "; for (auto c :even) cout<<c<<", "; cout<<endl; return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue