How would you search through the a list of vectors? I have a upper case letter at the start of the lists and corresponding lower case letters in vectors how would I search through it to see how many times the corresponding lower case letter was repeated?
void armazenaFA( std::vector <int> &vFA) // this function only knows about vFA { vsFA[n] [m]= simTime().dbl(); OR vsFA[n].push_back(simTime().dbl()); }
Make an ordered array. Put a bunch of random numbers into it. Do 20 linear searches and 20 binary searches of that array. (Code for linear search and binary search are found in the book.)Print out how many elements were checked before the item is found
I'm not looking for answers as it is homework. However I don't understand what I'm doing. This course is being held online(no other options) and that's not how I learn so I'm struggling. From my understanding I have to make a templated ordered array (which I don't understand at all) and then do searches (which I also don't understand).
Basically I need to make a program which asks for a business name and then keeps asking for more until user doesn't want to. Once more than 1 business is enter it should display the business and sort it alphabetically and keep displaying them each time another is added. I am lost on how to store the added business, sorting it and displaying the list.
Here is what I have so far.
#include <iostream> #include <string> #include <algorithm> #include <vector> using namespace std; int main () { string business_name; char selection;
This is probably a very basic question, but I need to create two vectors and then loop through the vectors and output each pair that is found.
The user will input min1 and max1 with step1 for the first vector and min2 and max2 and step2 for the second vector. Then the loops will go through and return the combinations will return each pair of the two vectors.
So if I input min1=1 and max1=10 and step1=1 and same for vector two the return would be:
[1,1] [1,2] . . . [10,10]
This is for part of a homework assignment, but I can't continue on the assignment without first getting this simple part to work.
I have an assignment to create an address book in c++ where you can enter contact information and then search all entries via last name. I am trouble figuring out how to write a function that will be able to search an entry by last name. Here is my code so far:
#include <iostream> using namespace::std; class addBook {
For action, if user enters action, it will output the bones involved with that action. For strengthening, if user enters location, it will output bones involved with that location. For dagnostic, if user enters bone, it will output location of bone and whether bone is deep/superficial.
WPF window I'm working on. I have a window that has a textbox to enter a name to search a database table for, and when the search button is clicked, the ID for that username will be returned to a separate textbox. The code I've written atm doesn't seem to be working, but it looks fine to me. Here's what I've got;
private void btn_SearchUsers_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrWhiteSpace(txtb_SearchName.Text)) { SqlConnection sqlCon = new SqlConnection(conStr);
[Code] .....
So, I have the value entered into the textbox to be searched for stored in a variable, I'm selecting the ID from the table when the name in the variable is found, storing the result in a DataTable, and then in my foreach loop, if I find the name (the name column being index 1 in the table), I set set the ID result textbox to equal the ID for that name (the ID column being index 0 in the table). I think the foreach part is what's throwing me off. Maybe the column stuff? My Users table is like;
I'm trying to write function that finds wheter the searched word exists or not. The compiler gives warning. Where is my wrong ?
|21|warning: passing argument 1 of 'strcmp' makes pointer from integer without a cast [enabled by default]|
Code:
#include <stdio.h> #include <string.h> int main () { int result; char arr[]="sakir emmim evde mi evde mi dedik lan"; int size=sizeof(arr)/sizeof(char); char key[20]; scanf("%s", &key);
I am trying to write a program to search a library file with the name of a book or author and return the books that match the searched string in some way. For instance, if I search "Develop" it should display Game Development Essentials(Novak) and Developing Games in Java(Brackeen) and tell me that 2 records were found. Currently, it shows all the records regardless of what i search for, even if it is jibberish. Am I missing something in my functions? should I include the code that accesses these functions?
//If the user chooses A or a int showBooksByAuthor (int count, string name) { char choice; int index = 0; }
I have a multimap with over 300k entries defined like so: std::multimap<std::string, std::string> filedata;
Using the following code and std::multimap::equal_range, I am able to successfully search for a word in the multimap and get needed data:
// Data with strings. data = std::vector<std::string>(); // Get iterators to matched pairs. std::pair <std::multimap<std::string, std::string>::iterator, std::multimap<std::string, std::string>::iterator> dat = filedata.equal_range(word); // Go through each matched pair and get needed info. for (std::multimap<std::string, std::string>::iterator iter = dat.first; iter != dat.second; iter++) { data.push_back(iter->second); }
Now, I would like to search the multimap using regular expressions (EX: std::regex("[a-z][a-e]h")). What is the fastest way to do this? Example code may look like:
std::pair <std::multimap<std::string, std::string>::iterator, std::multimap<std::string, std::string>::iterator> dat = filedata.equal_range_with_regex(std::regex("" + word + ""));. Pseudo-code / algorithms will be enough.
How do i search a csv file?. I have a table with 3 columns (Employee ID , salary ,grade ) If i will enter an Employee ID and it should return the salary and grade of that employee id.
im trying to make a function that will take in a users ID and search a text file for that ID and if there is a match to print out the matched line and the following 3 lines that follow. so far i ahve the following code but i cant get that to work and i dont knwo how to do the rest.
//declaring a file variable FILE *fpcust; int line_num = 1;
So I have an array of distinct pairs of natural numbers. That is, my array looks something like this (for instance):
{ (1,5) , (6,4), (5,3), (2,3), (2,4) }
And my task is, for a given pair (a,b) find (if it exists) the pair (c,d) which has c > a and d > b and, in addition, is the "minimal" such pair (that is, c is minimal and, if there are multiple pairs which satisfy this with the same c, then d is minimal.
So for instance, if I run the query for the above array for pair (1,1), it should return (2,3) and if I feed it (5,2) it should return (6,4).
Now the problem is that I have to run multiple queries so linear time is not good enough. And my question is: is there any way in / any law by which I can "sort" such an array so that I can later run binary searches on it to find my answer?
I was thinking I could simply go like this: let (x1,y1) and (x2,y2) be two pairs to compare. Then:
if(x1<x2) //pair 1 is smaller else if(x1==x2 && y1<y2) //pair 1 is smaller else //pair 2 is smaller
This seemed to solve most cases, however.. if I have an array which looks like this:
{ .... (50,60) ..... }
where (50, 60) is at the middle of the array. And I run a query for (40,70) for instance. The problem is that the pair that I want to find could be either on the left or on the right of (50,60) (we could have something like (45,90) on the right of (50, 60), but then again we could only have (x,10) on the left of (50,60) where x<50 so no pair on the left would satisfy our condition and I'd have to look to the right).
So to sum it up, if I'm running a query for pair (x1,y1) and through my binary search I come across and element (x2,y2) which has x1<x2 and y1>=y2, then my algorithm cannot decide whether it should keep searching left or right. So I have to search both sides and in a worst case scenario this ends up being O(n).
Currently im creating a simple phone directory. I am having a problem when searching the vector. It only lets me search for the exact key in the directory when I need to to search for strings that are close to the name. For example when I search "car" it will state that its not in the directory when it should pull up Carr, Derek and Carr David.
I'm trying to find a < character in a document, get it's position. Then find > and get it's position. Then i want to delete all things between that but runtime is terminating my process so i don't know what to do.
Basically I initialize an int array of size 10 with zeros. Then element 7 is changed to 1. Via cin I collect a user input (integer) which is the number to be searched.
Now the problem is that the search function from the book is somehow not working. I added a function to see how the array looks like and there is definitely one element with value 1 that should be found, but it simply isn't. The function always returns -1 (element not found).
The program compiles, but doesn't work as it is supposed to.
//******************************************************** // search algorithm for arrays //******************************************************** #include <iostream> using namespace std;
I've almost got my code working. My issue is, if I type in either one of the first two id numbers, it finds the person and displays as it's supposed to, however if I type any of the last 6 id numbers it says id not found. I've been staring at this forever and can't see what I'm missing />/> ps, I haven't added in all my comments yet Binary tree template
//Binray tree template class #ifndef BINARYTREE_H #define BINARYTREE_H
i use cygwin and i have a program that was returning an error saying "undefined reference" and i figured out that i misspelled a word. how can i search for the misspelling in the input mode, if ive just completed a very large program and dont want to scroll through possibly 300+ lines of input? im not totally out the loop, but i know i can "vim program.cpp" to open the program, but before clicking "i" to actually edit, there must be a way to search a word
So I been asked to write a program that does the following:
Write a program that allows the user to enter a series of 10 names from the keyboard and then sorts and prints the names in alphabetical order. Use a series of functions:
1) Input the data 2) Sort the data (use a bubble sort) 3) Print the data
After this is done, allow the user to enter a name from the keyboard and determine if the name appears in the list. Use a function to accomplish the search. The name to be searched for should be input within main and sent to the function as an argument.
4) Search the data (use a binary search of type bool)"
this is whats I wrote so far and its giving me error with the sorting and the searching, I need to fix it and I cannot figure out how?!.
#include <iostream> #include <conio.h> #include <string> using namespace std; void bubbleSort(string[], int); int main()
I have a problem with searching chars by diagonal not only the main, i have a chars in vector and I need to go though all possibilities (as shown in picture) the word has to be side/2 long so here i have 9, so word has to be 4 chars long how I need to do this?
I have to search an array of struct students on the basis of their first names, last names and roll numbers .. so far i am done with the input of the student first , last names and roll numbers . I have problem in searching the array ..
I want to make a program that receives the number of lines and collumns of a matrix, a matrix of char, the number of pairs of coordinates and the coordinates. the program has to return the char (or chars) that are on those coordinates on the matrix.
Example:
receives 2 3 ABC DEF 2 1 1 1 2
returns
AB
this is how i tried to solve this problem:
Code: #include #define MAX 1000 int main() { int nlin, ncol; char mat[MAX][MAX]; int x[MAX], y[MAX]; int ncoords; int l, c, n;
/* receiving variables and storing matrix.*/
[Code] .....
For some reason that i can't seem to find, this solution is not right.