This commit is contained in:
RafayAhmad7548 2024-09-09 16:59:28 +05:00
parent 2992f4f408
commit 4f46de8d00
3330 changed files with 394553 additions and 76939 deletions

View file

@ -0,0 +1,78 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class CustomerList{
int* customerIds;
int size;
int capacity;
void increaseCapacity(){
int* newArr = new int[size*2];
for(int j=0;j<size;j++){
newArr[j] = customerIds[j];
}
delete[] customerIds;
customerIds = newArr;
size *= 2;
}
public:
CustomerList() : size(0), capacity(10){
customerIds = new int[capacity];
}
~CustomerList(){
delete[] customerIds;
}
void addCustomer(int customerId){
if(size >= capacity) increaseCapacity();
customerIds[size] = customerId;
size++;
}
int findCustomer(int customerId){
for(int i=0;i<size;i++){
if(customerIds[i] == customerId) return i;
}
return -1;
}
bool removeCustomer(int customerId){
bool removed = false;
for(int i=0;i<size;i++){
if(customerIds[i] == customerId){
for(int j=i;j<size-1;j++){
customerIds[j] = customerIds[j+1];
}
removed = true;
size--;
break;
}
}
return removed;
}
void printList(){
for(int i=0;i<size;i++){
cout<<customerIds[i]<<endl;
}
}
};
int main(){
CustomerList list;
list.addCustomer(1);
list.addCustomer(2);
list.addCustomer(3);
list.addCustomer(4);
list.printList();
return 0;
}

View file

@ -0,0 +1,43 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class CustomerList{
int* customerIds;
int size;
int capacity;
void increaseCapacity(){
int* newArr = new int[size*2];
for(int j=0;j<size;j++){
newArr[j] = customerIds[j];
}
delete[] customerIds;
customerIds = newArr;
size *= 2;
}
public:
CustomerList() : size(0), capacity(10){
customerIds = new int[capacity];
}
~CustomerList(){
delete[] customerIds;
}
void addCustomer(int customerId){
if(size >= capacity) increaseCapacity();
customerIds[size] = customerId;
size++;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,23 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class CustomerList{
int* customerId;
int size;
int capacity;
public:
CustomerList() : size(0), capacity(10){
customerId = new int[capacity];
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,82 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class CustomerList{
int* customerIds;
int size;
int capacity;
void increaseCapacity(){
int* newArr = new int[size*2];
for(int j=0;j<size;j++){
newArr[j] = customerIds[j];
}
delete[] customerIds;
customerIds = newArr;
size *= 2;
}
public:
CustomerList() : size(0), capacity(10){
customerIds = new int[capacity];
}
~CustomerList(){
delete[] customerIds;
}
void addCustomer(int customerId){
if(size >= capacity) increaseCapacity();
customerIds[size] = customerId;
size++;
}
int findCustomer(int customerId){
for(int i=0;i<size;i++){
if(customerIds[i] == customerId) return i;
}
return -1;
}
bool removeCustomer(int customerId){
bool removed = false;
for(int i=0;i<size;i++){
if(customerIds[i] == customerId){
for(int j=i;j<size-1;j++){
customerIds[j] = customerIds[j+1];
}
removed = true;
size--;
break;
}
}
return removed;
}
void printList(){
for(int i=0;i<size;i++){
cout<<customerIds[i]<<endl;
}
}
};
int main(){
CustomerList list;
list.addCustomer(1);
list.addCustomer(2);
list.addCustomer(3);
list.addCustomer(4);
list.removeCustomer(3);
cout<<list.findCustomer(4)<<endl;
list.printList();
return 0;
}

View file

@ -0,0 +1,31 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class CustomerList{
int* customerIds;
int size;
int capacity;
public:
CustomerList() : size(0), capacity(10){
customerIds = new int[capacity];
}
~CustomerList(){
delete[] customerIds;
}
void addCustomer(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,49 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class CustomerList{
int* customerIds;
int size;
int capacity;
void increaseCapacity(){
int* newArr = new int[size*2];
for(int j=0;j<size;j++){
newArr[j] = customerIds[j];
}
delete[] customerIds;
customerIds = newArr;
size *= 2;
}
public:
CustomerList() : size(0), capacity(10){
customerIds = new int[capacity];
}
~CustomerList(){
delete[] customerIds;
}
void addCustomer(int customerId){
if(size >= capacity) increaseCapacity();
customerIds[size] = customerId;
size++;
}
bool removeCustomer(int customerId){
for(int i=0;i<size;i++){
}
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,60 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class CustomerList{
int* customerIds;
int size;
int capacity;
void increaseCapacity(){
int* newArr = new int[size*2];
for(int j=0;j<size;j++){
newArr[j] = customerIds[j];
}
delete[] customerIds;
customerIds = newArr;
size *= 2;
}
public:
CustomerList() : size(0), capacity(10){
customerIds = new int[capacity];
}
~CustomerList(){
delete[] customerIds;
}
void addCustomer(int customerId){
if(size >= capacity) increaseCapacity();
customerIds[size] = customerId;
size++;
}
int findCustomer(int customerId){
for(int i=0;i<size;i++){
if(customerIds[i] == customerId) return i;
}
return -1;
}
bool removeCustomer(int customerId){
for(int i=0;i<size;i++){
if(customerIds[i] == customerId){
for(int j=i;j<size-1;j++){
customerIds[j] = customerIds[j+1];
}
}
}
}
};
int main(){
return 0;
}

View file

@ -0,0 +1 @@
{"version":1,"resource":"file:///home/rafayahmad/Stuff/Coding/C%2B%2B/DS/lab2/task4.cpp","entries":[{"id":"lMlb.cpp","timestamp":1725282148006},{"id":"DkSd.cpp","timestamp":1725282272489},{"id":"I9Hy.cpp","timestamp":1725282317389},{"id":"rAs9.cpp","timestamp":1725282378434},{"id":"6FVY.cpp","timestamp":1725282408164},{"id":"OUSs.cpp","timestamp":1725282492316},{"id":"u1CW.cpp","timestamp":1725282525027},{"id":"RDem.cpp","timestamp":1725282573728},{"id":"nBnA.cpp","timestamp":1725282614685},{"id":"n2eg.cpp","timestamp":1725283103346},{"id":"55T2.cpp","timestamp":1725283152114},{"id":"klwK.cpp","timestamp":1725283178526},{"id":"GYP6.cpp","timestamp":1725283194345}]}

View file

@ -0,0 +1,80 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class CustomerList{
int* customerIds;
int size;
int capacity;
void increaseCapacity(){
int* newArr = new int[size*2];
for(int j=0;j<size;j++){
newArr[j] = customerIds[j];
}
delete[] customerIds;
customerIds = newArr;
size *= 2;
}
public:
CustomerList() : size(0), capacity(10){
customerIds = new int[capacity];
}
~CustomerList(){
delete[] customerIds;
}
void addCustomer(int customerId){
if(size >= capacity) increaseCapacity();
customerIds[size] = customerId;
size++;
}
int findCustomer(int customerId){
for(int i=0;i<size;i++){
if(customerIds[i] == customerId) return i;
}
return -1;
}
bool removeCustomer(int customerId){
bool removed = false;
for(int i=0;i<size;i++){
if(customerIds[i] == customerId){
for(int j=i;j<size-1;j++){
customerIds[j] = customerIds[j+1];
}
removed = true;
size--;
break;
}
}
return removed;
}
void printList(){
for(int i=0;i<size;i++){
cout<<customerIds[i]<<endl;
}
}
};
int main(){
CustomerList list;
list.addCustomer(1);
list.addCustomer(2);
list.addCustomer(3);
list.addCustomer(4);
cout<<list.findCustomer(4)<<endl;
list.printList();
return 0;
}

View file

@ -0,0 +1,13 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int main(){
return 0;
}

View file

@ -0,0 +1,71 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class CustomerList{
int* customerIds;
int size;
int capacity;
void increaseCapacity(){
int* newArr = new int[size*2];
for(int j=0;j<size;j++){
newArr[j] = customerIds[j];
}
delete[] customerIds;
customerIds = newArr;
size *= 2;
}
public:
CustomerList() : size(0), capacity(10){
customerIds = new int[capacity];
}
~CustomerList(){
delete[] customerIds;
}
void addCustomer(int customerId){
if(size >= capacity) increaseCapacity();
customerIds[size] = customerId;
size++;
}
int findCustomer(int customerId){
for(int i=0;i<size;i++){
if(customerIds[i] == customerId) return i;
}
return -1;
}
bool removeCustomer(int customerId){
bool removed = false;
for(int i=0;i<size;i++){
if(customerIds[i] == customerId){
for(int j=i;j<size-1;j++){
customerIds[j] = customerIds[j+1];
}
removed = true;
size--;
break;
}
}
return removed;
}
void printList(){
for(int i=0;i<size;i++){
cout<<customerIds[i]<<endl;
}
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,65 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class CustomerList{
int* customerIds;
int size;
int capacity;
void increaseCapacity(){
int* newArr = new int[size*2];
for(int j=0;j<size;j++){
newArr[j] = customerIds[j];
}
delete[] customerIds;
customerIds = newArr;
size *= 2;
}
public:
CustomerList() : size(0), capacity(10){
customerIds = new int[capacity];
}
~CustomerList(){
delete[] customerIds;
}
void addCustomer(int customerId){
if(size >= capacity) increaseCapacity();
customerIds[size] = customerId;
size++;
}
int findCustomer(int customerId){
for(int i=0;i<size;i++){
if(customerIds[i] == customerId) return i;
}
return -1;
}
bool removeCustomer(int customerId){
bool removed = false;
for(int i=0;i<size;i++){
if(customerIds[i] == customerId){
for(int j=i;j<size-1;j++){
customerIds[j] = customerIds[j+1];
}
removed = true;
size--;
break;
}
}
return removed;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,33 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class CustomerList{
int* customerIds;
int size;
int capacity;
public:
CustomerList() : size(0), capacity(10){
customerIds = new int[capacity];
}
~CustomerList(){
delete[] customerIds;
}
void addCustomer(int customerId){
if(size >= capacity) increaseCapacity();
customerIds[size] = customerId;
size++;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,56 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class CustomerList{
int* customerIds;
int size;
int capacity;
void increaseCapacity(){
int* newArr = new int[size*2];
for(int j=0;j<size;j++){
newArr[j] = customerIds[j];
}
delete[] customerIds;
customerIds = newArr;
size *= 2;
}
public:
CustomerList() : size(0), capacity(10){
customerIds = new int[capacity];
}
~CustomerList(){
delete[] customerIds;
}
void addCustomer(int customerId){
if(size >= capacity) increaseCapacity();
customerIds[size] = customerId;
size++;
}
int findCustomer(int customerId){
for(int i=0;i<size;i++){
if(customerIds[i] == customerId) return i;
}
return -1;
}
bool removeCustomer(int customerId){
for(int i=0;i<size;i++){
}
}
};
int main(){
return 0;
}