Last active
August 29, 2015 14:10
-
-
Save BeniaminK/389d14f8de27f89599a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
double tab[10] = { 7, 8, 6, 4, 5, 9, 0, 3, 1, 2 }; | |
double srednia = 0; | |
for (int i = 0; i < 10; i++) | |
{ | |
cout << tab[i] << "\t"; | |
} | |
cout << "------------------------------------------------------------------" << endl; | |
double *wskaznik; | |
wskaznik = &tab[0]; | |
int ile; | |
cout << "ile chcesz wyrazow z tablicy, a z tylu policze ci srednia: "; | |
cin >> ile; | |
cout << endl; | |
for (int i = 0; i < ile; i++) | |
{ | |
srednia += *wskaznik; | |
wskaznik++; | |
} | |
srednia = srednia / ile; | |
cout << "srednia wynosi " << srednia << endl << endl << endl << endl << endl; | |
cout << "to tablica po przejsciu ze wskaznikiem: " << endl; | |
cout << "------------------------------------------------------------------" << endl; | |
wskaznik = tab; | |
for (int i = 0; i < 10; i++) | |
{ | |
cout << *wskaznik << "\t"; | |
*wskaznik++; | |
} | |
cout << endl << endl << endl<<endl << "to tablica po przejsciu bez wskaznika" << endl; | |
cout << "------------------------------------------------------------------" << endl; | |
for (int i = 0; i < 10; i++) | |
{ | |
cout << tab[i] << "\t"; | |
} | |
cout << "\n"; | |
system("pause"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment