SalomIsm String formatida ism berilgan, masalan “Otabek”,ismdan foydlanib “Salom Otabek!” ko`rinishidagi qiymat qaytarilsin


Agar berilgan sart oxiri “ly” bilan tugasa true qiymat qaytarilsin


Download 110 Kb.
bet3/8
Sana08.01.2022
Hajmi110 Kb.
#234790
1   2   3   4   5   6   7   8
Bog'liq
CodingBat String 1

Agar berilgan sart oxiri “ly” bilan tugasa true qiymat qaytarilsin.







String-1 > nTwice 
prev  |  next  |  chance

Given a string and an int n, return a string made of the first and last n chars from the string. The string length will be at least n.

nIkkiMarta

Satr va n butun son berilgan, berilgan satrning birinchi va oxirgi n ta simvolidan hosil bo`lgan satr qaytaring. Bunda satr uzunligi kamida n ga teng bo`ladi.


String-1 > twoChar 
prev  |  next  |  chance

Given a string and an index, return a string length 2 starting at the given index. If the index is too big or too small to define a string length 2, use the first 2 chars. The string length will be at least 2.

ikkiBelgi

Satr va indeks berilgan bo`lib, sartning berilgan indeksidan boshlab 2 ta belgisini qaytaring. Agar indeks qiymati 2 ta simvol chiqarish uchun yetarli bo`lmagan holatda juda katta yoki juda kichik bo`lsa

twoChar("java", 0) → "ja"


twoChar("java", 2) → "va"
twoChar("java", 3) → "ja"

String-1 > middleThree 
prev  |  next  |  chance

Given a string of odd length, return the string length 3 from its middle, so "Candy" yields "and". The string length will be at least 3.

o`rtadagi3

Toq uzunlikdagi satr berilgan, berilgan satrning o`rtasidagi 3 ta belgidan yangi satr qaytaring. Masalan: “Storm” dan “tor” so`zi hosil bo`ladi. Bunda satr uzunligi kamida 3 ga teng bo`ladi.


String-1 > hasBad 
prev  |  next  |  chance

Given a string, return true if "bad" appears starting at index 0 or 1 in the string, such as with "badxxx" or "xbadxx" but not "xxbadxx". The string may be any length, including 0. Note: use .equals() to compare 2 strings.

hasBad

Sart berilgan bo`lib agar unda “bad” so`zi satrning 0 yoki 1-indeksidan boshlab bor bo`lsa true qiymat qaytarilsin. Masalan: “badxxx” yoki “xbadxx” so`zi bilan true qiymat lekin “xxbadxx” so`zi bilan false qiymat qaytariladi. Eslatma: str.equals() funksiyasi ikkita satrni solishtirish uchun ishlatiladi.

hasBad("badxx") → true


hasBad("xbadxx") → true
hasBad("xxbadxx") → false

String-1 > atFirst 
prev  |  next  |  chance

Given a string, return a string length 2 made of its first 2 chars. If the string length is less than 2, use '@' for the missing chars.

Birinchidan


Download 110 Kb.

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




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