Tajriba ishi 9


Download 216.5 Kb.
bet9/9
Sana09.06.2023
Hajmi216.5 Kb.
#1468852
1   2   3   4   5   6   7   8   9
Bog'liq
Tajriba ishi 9 0 Paradigmalar Xusinov Shaxriyor

Dastur natijasi n=8
kirit=1 kirit=2 kirit=3 kirit=4 kirit=5 kirit=6 kirit=7 kirit=8 dek ele-tlari=4 3 2 1 5 6 7 8 dek ele-tlari=4 8 2 6


Topshiriq


Variantlar:

  1. Kiritilgan ismning harflarini alfavit bo”yicha tartibga keltiring.

package Lab9;

import java.util.Arrays;


public class first {
public static void main(String[] args)
{
String inputString = "Shaxriyor";
String outputString = sortString(inputString);
System.out.println("Input String : " + inputString);
System.out.println("Output String : " + outputString);
}

// Alfabit bo'yicha saralaydigan sortString funksiyasi
public static String sortString(String inputString)
{
char tempArray[] = inputString.toCharArray();
Arrays.sort(tempArray);
return new String(tempArray);
}
}




  1. Stekning eng kata elementini toping.

#include


#include

using namespace std;


void findMax(stack s)


{
int m = s.top();
int a;

while (!s.empty())


{
a = s.top();

if (m < a)


m = a;
s.pop();
}
cout << "\n\n Stackning maxsimal elementi: " << m << endl;
}
void show(stack s)
{
while (!s.empty())
{
cout << " " << s.top();
s.pop();
}

cout << endl;


}

int main()


{
int i;
stack s;

s.push(4);


s.push(2);
s.push(20);
s.push(12);
s.push(52);
s.push(14);

show(s);
findMax(s);


return 0;
}

Download 216.5 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling