Hi I got error C2660 : 'valuein' : function does not take 2 parameters in visual studio 2013
this is my code so far
#include <cstdlib>
#include <list>
#include <iostream>
using namespace std;
struct node
{
int data;
node* next;
};
void initialize(node*p);
void insert(int data,int n);
void remove(int b,int pos);
bool empty(node*);
void length();
bool valuein(int c);
int reportvalue(int value);
void ptintlist();
int menu();
int main()
{
struct node*head=NULL;
char commands;
int value;
int pos = 0;
cout << "This program responds to commands
the user enters to\nmanipulate an ordered list of integers, which
is\ninitially empty. In the following commands, k1 is a\nposition
in the list, and v is an integer." << endl;
cout << "e -- Re-initialize the list to be
empty.\ni v -- Insert the value v into the list.\nr v -- Remove the
value v from the list.\nm -- Is the list empty ? \nl -- Report the
length of the list.\np v -- Is the value v present in the list ?
\nk k1 -- Report the k1th value in the list.\nw -- Write out the
list.\nh -- See this menu.\nq -- Quit." << endl;
cout << "-->";
cin >> commands;
do
{
switch (commands)
{
case 'e':
initialize(head->next);
case 'i':
{cin >> value;
insert(value, pos);
pos++;
}
case 'r':
{ cin >> value;
}
case'k':
{ cin >> value;
if (valuein(head, value) ==
true)
{
cout <<
"it is" << endl;
}
}
}
system("pause");
return 0;
} while (commands != 'q');
}
bool empty(node*)
{
node *root;
if (root->next == NULL)
return true;
else
return false;
}
void initialize(node*p)
{
node *temp;
if (p == NULL){
return;
}
temp = p;
initialize(p->next);
delete temp;
}
void insert(int data, int pos)
{
node*head = new node;
node* prev = new node();
node* curr = new node();
node* newNode = new node();
newNode->data = data;
int tempPos = 0; // Traverses through the list
curr = head; // Initialize
current to head;
if (head != NULL)
{
while
(curr->next != NULL && tempPos != pos)
{
prev = curr;
curr = curr->next;
tempPos++;
}
}
}
bool valuein(node*head, int x)
{
bool judge=false;
struct node* current = head; //
Initialize current
while (current != NULL)
{
if
(current->data == x)
judge=true;
current =
current->next;
}
return judge;
}
The code is not finished yet.. If you find other mistake I made
please let me know. Thank you!
#include <cstdlib> #include <list> #include <iostream> using namespace std; struct node { int data; node *next; }; void initialize(node *p); void insert(int data, int n); void remove(int b, int pos); bool empty(node *); void length(); bool valuein(node *head, int x); int reportvalue(int value); void ptintlist(); int menu(); int main() { struct node *head = NULL; char commands; int value; int pos = 0; cout << "This program responds to commands the user enters to manipulate an ordered list of integers, which is initially empty. In the following commands, k1 is a position in the list, and v is an integer." << endl; cout << "e -- Re-initialize the list to be empty. i v -- Insert the value v into the list. r v -- Remove the value v from the list. m -- Is the list empty ? l -- Report the length of the list. p v -- Is the value v present in the list ? k k1 -- Report the k1th value in the list. w -- Write out the list. h -- See this menu. q -- Quit." << endl; cout << "-->"; cin >> commands; do { switch (commands) { case 'e': initialize(head->next); case 'i': { cin >> value; insert(value, pos); pos++; } case 'r': { cin >> value; } case 'k': { cin >> value; if (valuein(head, value) == true) { cout << "it is" << endl; } } } system("pause"); return 0; } while (commands != 'q'); } bool empty(node *) { node *root; if (root->next == NULL) return true; else return false; } void initialize(node *p) { node *temp; if (p == NULL) { return; } temp = p; initialize(p->next); delete temp; } void insert(int data, int pos) { node *head = new node; node *prev = new node(); node *curr = new node(); node *newNode = new node(); newNode->data = data; int tempPos = 0; // Traverses through the list curr = head; // Initialize current to head; if (head != NULL) { while (curr->next != NULL && tempPos != pos) { prev = curr; curr = curr->next; tempPos++; } } } bool valuein(node *head, int x) { bool judge = false; struct node *current = head; // Initialize current while (current != NULL) { if (current->data == x) judge = true; current = current->next; } return judge; }
Hi I got error C2660 : 'valuein' : function does not take 2 parameters in visual...
Requirements: Finish all the functions which have been declared inside the hpp file. Details: string toString(void) const Return a visible list using '->' to show the linked relation which is a string like: 1->2->3->4->5->NULL void insert(int position, const int& data) Add an element at the given position: example0: 1->3->4->5->NULL instert(1, 2); 1->2->3->4->5->NULL example1: NULL insert(0, 1) 1->NULL void list::erase(int position) Erase the element at the given position 1->2->3->4->5->NULL erase(0) 2->3->4->5->NULL //main.cpp #include <iostream> #include <string> #include "SimpleList.hpp" using std::cin; using...
Your task is to complete the following function/functions: 1. Given a position in the linked list, delete the node at that position.(Silver problem - Mandatory ) 2. Print the sum of all negative elements in the linked list.(Gold problem) If you want, you can refer to the the previous recitation manual (which was on Linked Lists) to implement node deletion. #include <iostream> using namespace std; //----------- Define Node --------------------------------------------------- struct Node{ int key; Node *next; }; //----------- Define Linked List...
Hi I've a problem with this code. When I add more than 1 song to the list, it doesn't show the first one, only shows the latest one, when I called the function displaysong, let's say when you add 2 songs ID 1 then ID 2, it shows only ID 1. Can you fix it. Everything else is fine.. #include <iostream> #include<string> using namespace std; //class Song class Song{ private: int songID; string title; string artist; string album; int year; public:...
C++ - I have a doubly linked list, but I haven't been able to get the "reverse list" option in the code to work(It's option #in the menu in the program). I received this guidance for testing: Test 4 cases by entering (in this order) c,a,z,k,l,m This tests empty list, head of list, end of list and middle of list. Then delete (in this order) a,z,l. This tests beginning, end and middle deletes. This exhaustively tests for pointer errors. #include...
C++: I need implement this code using Double Linked List using the cosiderations 1. head point to null in an empty list 2. There is not need of a tail pointer /*This class implements the singly linked list using templates Each list has two attributes: -head: first node in the list -tail: last node in the list #include "circDLLNode.h" template class { public: //Default constructor: creates an empty list (); //Destructor: deallocate memory ~(); ...
C++ comment code Comment the following code #include <iostream> using namespace std; class Node { public: Node(int val); int value; Node* next; }; Node::Node(int val){ value = val; } class List { public: List(); // Uncomment the line below once you're ready List(List &other); void push_front(int value); bool pop_front(int &value); void push_back(int value); bool pop_back(int &value); int at(int index); void insert_at(int index, int value); void remove_at(int index); int size(); private: // other members you may have used Node* head; Node*...
Hi, I hope I can get some help with the following exercise in C++( CPP): 1.Write an additional method called push_back(int) that will add an integer to the end of the list. You can modify the provided code. 2.Modify the Node class and LinkedList class so that you can access your parent node (double linked-list). #include #include using namespace std; typedef int Type; enum Boolean { False = 0, True }; class Item { friend class SLList; public: Type getVal()...
(C++) You are tasked with implementing a recursive function void distanceFrom(int key) on the IntList class (provided). The function will first search through the list for the provided key, and then, recursively, change all previous values in the list to instead be their distance from the node containing the key value. Do not update the node containing the key value or any nodes after it. If the key does not exist in the list, each node should contain its distance...
I have a C++ code that lets me enter, display and delete a
student record. I need to implement a function that prints the
average grade score of the students I input.
Below is my code and a picture of how my code looks right
now.
#include<iostream>
#include<stdlib.h>
using namespace std;
//Node Declaration
struct node
{
string name;
string id;
int score;
node *next;
};
//List class
class list
{
private:
//head...
1) Create a struct called CourseInfo to store info about a course (Include variables for courseNum, courseName, & grade) 2) Change the type for the 'data' member variable in the node struct to CourseInfo (see #1) and rename it to 'courseData' 3) Modify the createNode function to receive a CourseInfo struct as a parameter. It should also display the address of the new node that is created. Display the address in both hex and decimal form. 4) Modify the display...