1. def remove(list1, pos): newlist = []


Download 12.82 Kb.
Sana30.01.2023
Hajmi12.82 Kb.
#1140504
Bog'liq
Ma\'lumotlar tuzilmasi


1. def remove(list1, pos):
newlist = []

# traverse in the list


for x in range(len(list1)):

# if index not equal to pos


if x != pos:
newlist.append(list1[x]) 
print(*newlist)

# driver code


list1 = [10, 20, 30, 40, 50]
pos = 2
remove(list1, pos);
2. using namespace std;
vector deleteElement(int A[], int L, int R, int N)
{
vector B;
for (int i = 0; i < N; i++)
if (i <= L || i >= R)
B.push_back(A[i]);
return B;
}
// main Driver
int main()
{
int A[] = { 3, 5, 3, 4, 9, 3, 1, 6, 3, 11, 12, 3 };
int L = 2, R = 7;
int n = sizeof(A) / sizeof(A[0]);
vector res = deleteElement(A, L, R, n);
for (auto x : res)
cout << x << " ";
return 0;
}
3.int main()
{
deque mydeque{ 1, 2, 3, 4, 5 };
mydeque.clear();
// Deque becomes empty
// Printing the deque
for (auto it = mydeque.begin(); it != mydeque.end(); ++it)
cout << ' ' << *it;
return 0;
}
4. int main()
{
deque mydeque;
mydeque.push_front(1);
// deque becomes 1
if (mydeque.empty()) {
cout << "True";
}
else {
cout << "False";
}
return 0;
}

Download 12.82 Kb.

Do'stlaringiz bilan baham:




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