order + update
This commit is contained in:
parent
61570e1c63
commit
eee0a5263e
7
.vscode/settings.json
vendored
Normal file
7
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"*.embeddedhtml": "html",
|
||||||
|
"iostream": "cpp",
|
||||||
|
"ostream": "cpp"
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ using namespace std;
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int a[] = {5,18,7,9,2,1,11,8,2,3};
|
int a[] = {5,18,7,9,2,1,11,8,2,3};
|
||||||
int i,k,max1,max2,n;
|
int i,k,b,c,max1,max2,max3,n;
|
||||||
|
|
||||||
n = sizeof(a)/sizeof(a[0]);
|
n = sizeof(a)/sizeof(a[0]);
|
||||||
max1 = a[0];
|
max1 = a[0];
|
||||||
@ -17,18 +17,36 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cout << "Najwiekszy element: " << max1 << endl;
|
cout << "Najwiekszy element: " << max1 << endl;
|
||||||
cout << "Indeks najwiekszego elementu: " << k << endl;
|
cout << "Indeks: " << k << endl << endl;
|
||||||
|
|
||||||
if(k == 0) max2 = a[1];
|
if(k == 0) max2 = a[1];
|
||||||
else max2 = a[0];
|
else max2 = a[0];
|
||||||
|
b = 0;
|
||||||
|
|
||||||
for(i=1; i<n; i++) {
|
for(i=1; i<n; i++) {
|
||||||
if(i!=k && a[i] > max2) {
|
if(i!=k && a[i] > max2) {
|
||||||
max2 = a[i];
|
max2 = a[i];
|
||||||
|
b = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(b == 0) max3 = a[2];
|
||||||
|
else max3 = a[0];
|
||||||
|
c = 0;
|
||||||
|
|
||||||
|
for(i=1; i<n; i++) {
|
||||||
|
if(i!=k && i!=b && a[i] > max3) {
|
||||||
|
max3 = a[i];
|
||||||
|
c = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "Drugi najwiekszy element: " << max2 << endl;
|
cout << "Drugi najwiekszy element: " << max2 << endl;
|
||||||
|
cout << "Indeks: " << b << endl;
|
||||||
|
cout << endl;
|
||||||
|
cout << "Trzeci najwiekszy element: " << max3 << endl;
|
||||||
|
cout << "Indeks: " << c << endl;
|
||||||
|
|
||||||
|
|
||||||
system("pause");
|
system("pause");
|
||||||
return 0;
|
return 0;
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user