Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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
You can’t perform that action at this time.