Professional Documents
Culture Documents
#include<iostream>
#include<cmath>
int main(){
int a,b,f=0,c=0,k=1;
cin>>a;
cin>>b;
double array[a][b+1];
for(int i=0;i<a;i++){
for(int j=0;j<b+1;j++){
cin>>array[i][j];
cout<<"output : \n";
double a0[a]={0},an[a];
while(1){
f=0;
for(int i=0;i<a;i++){
double sum=0.0;
for(int j=0;j<b;j++){
if(j!=i){
sum+=array[i][j]*a0[j];
}
an[i]=(array[i][a]-sum)/array[i][i];
for(int i=0;i<a;i++){
if(fabs(((an[i]-a0[i]))/a0[i])>error){
a0[i]=an[i];
f++;
c++;
k++;
if(c==10)
break;
}
Linear equation solving by Gauss-Seidel method
#include<iostream>
#include<cmath>
int main(){
int a,b,f=0,c=0,k=1;
cin>>a;
cin>>b;
double array[a][b+1];
for(int i=0;i<a;i++){
for(int j=0;j<b+1;j++){
cin>>array[i][j];
cout<<"output : \n";
double a0[a]={0},store;
while(1){
f=0;
for(int i=0;i<a;i++){
double sum=0.0;
for(int j=0;j<b;j++){
if(j!=i){
sum+=array[i][j]*a0[j];
store=(array[i][a]-sum)/array[i][i];
if(fabs(((store-a0[i]))/a0[i])>error){
a0[i]=store;
f++;
c++;
k++;
if(c==10)
break;
}}
write a program to implement the following task using linked list
structure
1. create a list in ascending order
2. display the item from the list
3. delete a specific item the list
#include <iostream>
using namespace std;
struct Node {
int data;
Node* next;
};
if (head == NULL) {
head = newNode;
return;
}
newNode->next = temp->next;
temp->next = newNode;
}
void display() {
Node* temp = head;
if (head == NULL) {
return;
}
if (head->data == value) {
head = head->next;
delete temp;
return;
}
if (temp->next == NULL) {
return;
}
int main() {
while(1){
cout<<"1. Create List()."<<endl;
cout<<"2. Display List()."<<endl;
cout<<"3. Delete List()."<<endl;
cout<<"4. Exit()"<<endl;
int i;
cout<<"Enter your choice : ";
cin>>i;
if(i==1){
int j;
cout<<"\n Insert item into the linked list : ";
cin>>j;
insert(j);
}
else if(i==2){
int j;
cout<<"\n Display item into the linked list : ";
display();
}
else if(i==3){
int j;
cout<<"\n Delete item position from the linked list : ";
cin>>j;
deleteItem(j);
}
else{
break;
}
}
return 0;
}
Output:
1. Create List().
2. Display List().
3. Delete List().
4. Exit()
Enter your choice : 1
Conclusion:
In conclusion, a linked list is a dynamic data structure that can be used to efficiently store a sequence of
elements. It offers efficient insertion and deletion of elements, but does not provide constant-time access
to individual elements. Despite its limitations, linked lists are widely used in computer science and are an
important concept to understand for anyone interested in programming.