February 2019 0 38 Report
C++, Zmodyfikuj kod programu, który jest poniżej, tak aby program wyświetlał drugi największy element tablicy.


#include

using namespace std;

int main()
{

int a;
int tab[30];
int d=tab[0];

cout << "podaj liczbe" << endl;
cin >> a;

if (a > 1)
{
if (a < 30)
{
cout << "podana liczba jest z zakresu 1-30" << endl;

for (int i = 0; i < a; i++)
{
cout << "podaj liczbe" << endl;
cin >> tab[i];
}

for (int i = 0; i < a; i++)
{
if (tab[i]>d)
{
d = tab[i];
}
}
cout << "najwieksza liczba: " << d;
}
else
cout << "podale liczbe spoza zakresu";
}

system("pause");
return 0;
}


More Questions From This User See All

Recommend Questions



Life Enjoy

" Life is not a problem to be solved but a reality to be experienced! "

Get in touch

Social

© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.