Skip to content

Instantly share code, notes, and snippets.

@BeniaminK
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BeniaminK/389d14f8de27f89599a6 to your computer and use it in GitHub Desktop.
Save BeniaminK/389d14f8de27f89599a6 to your computer and use it in GitHub Desktop.
#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