I am needing to write a program for someone that needs it to count by any number they manually enter into the program. I have the menu code written and now just need help with the counnting code. I know i most likely need to use a "for" loop but after that i am not sure.

Member Avatar
Member Avatar
+0 forum 5

Dear all, I need the code for counting sort algorithm but I try this code but is not working #include <iostream> #include <conio.h> #include <time.h> #include <stdlib.h> //srand and rand functions using namespace std; void add_random_numbers(long arr[], long b); void countingSort( long left, long right, long vector[], int k, long length); long const MADH_MAX_VEKTORIT = 110000; int main() { long random_vector[MADH_MAX_VEKTORIT]; long vector[] = { 1000, 10000, 15000, 25000, 30000, 45000, 50000, 60000, 75000, 90000, 100000 }; long num_elem; clock_t tn, tp; srand(time(NULL)); cout << "AlgorithmttNumbers_of_emelmentstttTime(s)n"; cout << "--------tt-------------------tt-------n"; for (long i = 0; i < 11; i++) { num_elem …

Member Avatar
Member Avatar
+0 forum 1

I am working on a code that searches a folder gets a specific part of the file name and adds 1 to a file counter. There are some files in tehre that have a special character that indicates that is is only half. I ahve got it to count the full ones but can not figure out a way to get the half ones to count. The special character that is in the names to inficate half is H. If someone could please help me figure this out it would help increase my production time. def bedCount(pathname, bednumber): filecount = …

Member Avatar
Member Avatar
+0 forum 3

I seem to be having difficulty with my code, I have tried many different ways but I can't seem to figure out how to implement some things. I'm also not sure how to setup my menu so only certain functions are called. 1. Adding a if statement under ShowMenu to check to see if the string word is lowercase or uppercase. Also Is there a better method that allows spacing different string method? 2. Couning Uppercase and Lowercase 3. Converting from Uppercase to Lowercase and vice versa I just can't seem to find out how to check to see my …

Member Avatar
Member Avatar
+0 forum 6

This is **Python** language. Hello, I'm trying to make a program where the user enters his/her initials followed by a block of text. After that, the program will print out the number of times his/her initials showed up in the block of text. For example, if my initials are VKL, and I type "Victor likes licking people" as the block of text (that's kinda gross), the program should print out "Your string contained 6 matches from your initials." 'V' appeared once, 'K' appeared twice, and 'L' appeared three times, so that adds up to 6. Below is the code I …

Member Avatar
Member Avatar
+0 forum 4

Okay so I have couple of questions about lists in vb.. Please be aware that it's all related to integers only no strings or others 1. How to sum values of a list? 2. How to sort values of list from highest to lowest? Also how would I display list values in a message box vertically? Example: ...........Message Box............ .1 .2 .3 .4 .5 .6 .................................. I appreciate any answers.. And please let me know if you need further information.

Member Avatar
Member Avatar
+0 forum 1

Hello, What is the best way to count the number of swaps required to sort an array that is sorted using the Quicksort algorithm? I put a counter in what I believe is in the correct position and the tests that I have run seem to be correct however Quicksort is so complex I do not trust my data. Thanks, /** The IntQuickSorter class provides a public static method for performing a QuickSort on an int array. */ public class IntQuickSorter2 { private static int track = 0; /** The quickSort method calls the doQuickSort method to sort an int …

Member Avatar
Member Avatar
+0 forum 5

Hello, What is the best way to check my code? I have written a program that counts the swaps required to sort an integer array using the Bubble, Selection, Insertion and Quick sort methods. How can I be absolutely certain that my swap counts are correct? Will someone take a look at my code and make a suggestion? Is there code on the web that will confirm my results? Thanks, Jim

Member Avatar
Member Avatar
+0 forum 4

Now that MITx first test is over, I got feeling that this one task requested for generate and test solution is begging also for less efficient recursive solution as it is so simple. Here it is! Single liner aproved by the released grader! If you wander if you are able to buy exactly n nuggets by boxes of 6, 9 or 20 nuggets each, it tells the answer. It does not tell you how heavy your shopping bags would be and how many geeks you need to eat them ;) This recursive version can not deal with 1000000 nuggets (using …

Member Avatar
+0 forum 0

I'm causing input letters to write ones into variables through an array. I'm trying to count the occurences of ones in a variable. Lets say I input aaaaa. The count output displays 12345. Instead of outputting the whole count of numbers, I want to output the biggest number in the count. How can I do that?

Member Avatar
Member Avatar
+0 forum 2

Quickselect, based on quicksort, and counting select, based on counting sort. Each is capable of finding the kth smallest element in an unsorted/sorted list/array. This is some example code for a QuickSelect algorithm. This doesn't include the partition function. // return the kth smallest item int quickSelect(int items[], int first, int last, int k) { int pivot = partition(items, first, last); if (k < pivot-first) { return quickSelect(items, first, pivot, k); } else if (k > pivot) { return quickSelect(items, pivot+1, last, k-pivot); } else { return items[k]; } } Counting select, based on the counting sort algorithm, looks something …

Member Avatar
Member Avatar
+0 forum 1

I have to find factors of 1-10 then count all factors and find if they are odd/even. I know how to find if they are even or odd i just can't count how many factors for each number. #include <iostream.h> #include <stdlib.h> int main() { int num, icntA, icntB, icntC, sub = 0.0; int total = 0.0; cout << "Please enter a positive maxiumum integer value you wish to find divisors: \n"; cin >> num; for(icntA = 1; icntA <= num; icntA++) { for(icntB = 1; icntB <= num; icntB++) { if(icntA % icntB == 0) cout << icntB << …

Member Avatar
Member Avatar
+0 forum 1

hi everyone i am very new to programming and really need some advice. i am currently building a program and one of the things i need is to be able to count the number of pages in pdf files in a directory. i found a script online which is suppose to do that but for some reason i can get it to work. im not completly sure what i have to change in the script for it to work for me could someone please help me and tell me what i have to change in the script to be able …

Member Avatar
+0 forum 0

This code prints coordinates for a square that another program uses. For space's sake I have cut out all the other program's code, but I believe it is a simple syntax mistake with my if() statements. I have followed the rules and looked just about everywhere and followed all of the C guidelines, but I keep getting 100 of the first coordinates followed by "no value". It seems that the program thinks ctr is not 0, where it is clearly defined.... Any reply would be appreciated.[CODE]int main() { int ctr; int stopctr=0; double xcoord[1]; double ycoord[1]; xcoord[0]=5; ycoord[0]=-5; ctr=0; do{ …

Member Avatar
Member Avatar
+0 forum 2

I am writing a program using J2ME and my goal is to count how many times each character appears in a string. I am not very good at java so the way i see i should do this is create 2 arrays. First array is used to hold characters. Second array is used to keep count The program goes through checks if the first character of the string is in the first array. If it isn't, then put it in the first position in the array and add 1 to its count in the second array. This loops through until …

Member Avatar
Member Avatar
+0 forum 4

In file i have a text. Words form line to line dont raising. Word in line separate least one space.Spaces can be at line begining and ending, can be empty lines. Count how many words can be in real number. i need a function whitch can count words whitch can be real number. I started like that this was first task, and now i need to count words, please help me ;/ [CODE]const char Cduom[] = "Duomenys.txt"; const char Crez[] = "Rezultatai.txt"; const char Canalize[] = "Analize.txt"; #include <string> #include <fstream> #include <iomanip> using namespace std; void ApdorotiTeksta(const char dfv[], …

Member Avatar
Member Avatar
+0 forum 3

[CODE]package com.abc.text; public class StringProcessing { /** * Returns the number of non-null strings in the set. * If null or a zero-length array is passed in, then zero is returned. * If a slot in the array is null, then it is ignored (not counted). */ public static int getCount(String[] set) { } /** * Returns the total length of all the non-null strings in the set. * If null or a zero-length array is passed in, then zero is returned. * If a slot in the array is null, then it is ignored (not counted). */ public static …

Member Avatar
Member Avatar
+0 forum 2

I have a sort of csv file which looks likes given below i want to count number of digits in each line like number of 0's ,1 s in each line and print them this way for each line i want to print information in csv file . 0 0 1 2 3 4 2 1 2 5 0 7 7 7 3 3 3 8 1 1 9 1 6 3 0 9 8 1 6 9 2 0 1 7 3 3 1 0 1 6 7 7 0 1 2 8 9 8 3 2 6 1 …

Member Avatar
Member Avatar
+0 forum 1

I am trying to write a function that will count test scores that fall in a specific range(90-100, 89-80, 79-70, 69-60 and 60 or below) that are stored in a two dimensional array. Also, I am supposed to write a function that will do the same as above, only this one will count the number of students whose test score average will fall into each of those ranges. Here is the code I have so far: [CODE] #include <iostream> #include <fstream> #include <string> #include <iomanip> using namespace std; void storeData(string studentNames[10], int scores[10][5]); void calculateData(int scores[10][5],double average[10], int& i, int& …

Member Avatar
Member Avatar
+0 forum 3

Hi! I am supposed to only use the "procedural fragment of C++", i.e. no object-oriented programming (like cin, cout etc). Vectors are not allowed either. So, one of my goals is to count the number of lines in a text file (let's call it train1.in) which contains data like: [ICODE] engine 15 engine 40 coach 30 boxcar 52[/ICODE] Now, I am supposed to count the number of cars (i.e. the number of lines in the file), which in this particular case is clearly 4 (two engines, a coach, a boxcar). Please tell me a simple way to do this. I …

Member Avatar
Member Avatar
-1 forum 14

this code is meant to input words from file, and output to file the amount of letters in them and how many words there are [CODE]#include<iostream> #include<iomanip> #include<fstream> #include<cmath> #include<conio.h> #define in_file "data.txt"//input file name #define out_file "result.txt"//output file name using namespace std; void inputwords(int&, int&); void outputwords(int, int); ifstream ins;// associates ins as an input stream ofstream outs;// associates outs as an output stream int letters=0; int words=0; char ch; int main() { ins.open(in_file);// associates ins as an input stream outs.open(out_file);// associates outs as an output stream bool charcheck; inputwords(letters, words); outputwords(letters, words); ins.close();// closing input file outs.close();// closing …

Member Avatar
Member Avatar
+0 forum 7

HELP!! can someone please help me, because i need to create a game in which i have to count how many times i've pressed enter in a matter of 1 minute.

Member Avatar
Member Avatar
+0 forum 5

This is a file named InBoundData.txt [TEX] 1 B777 850 Paris KL 9395 11.40 am 6 2100 2 B747 900 Lon KL 10000 12.30 pm 7 2100 3 A380 900 LA KL 16800 10.30 am 15 2750 4 A340 850 CapeTOWN kL 9580 12.10 pm 6 3000 5 A330 800 Seoul KL 4600 10.30 am -1 2300 6 A330 800 HongKong PEN 2800 2.00 pm 0 800[/TEX] How to make all this information into array file? izit possible to just declare inbounddata(which is the array) to be like [TEX]inbounddata[6][9][/TEX]? Will it read from the file? Can i take the number …

Member Avatar
Member Avatar
+0 forum 2

I cant seem to find the problem with this program I am building as a learning exercise. I am getting errors referenced to extremely simple pieces of code. In the output the first thing that should be printed is the random double number that the program selects then it should print the int conversion of that number. Then it should print the word that was selected from a file and the number of words in the file(29). Also is there a more efficient way to count the words in a file? If so how? [B]Here is the code:[/B] note: Line …

Member Avatar
Member Avatar
+0 forum 13

Hi~ I've been stuck with this exercise for quite a few days. It's in a book I'm currently self-studying, C++ primer plus. It is as follow: [CODE]/* Write a program that uses an array of char and a loop to read one word at a time until the word done is entered. The program should then report the number of words entered (not counting done). A sample run could look like this: Enter words (to stop, type the word done): anteater birthday category dumpster envy finagle geometry done for sure You entered a total of 7 words. You should include …

Member Avatar
Member Avatar
+0 forum 17

I need help counting the number of attempts to guess the right number. I can't seem to get the total number. I get an output like this 0+1+1+1+1+1 and so on. [CODE] secretNumber=$(( ((`date +%S`) % 59) +1 )) guess=-1 count=0 while [ "$guess" != "$secretNumber" ]; do count=$count+1 echo -n "Enter a guess between 0 and 59: " read guess if [ "$guess" = "" ]; then echo "Enter a number." elif [ "$guess" = "$secretNumber" ]; then echo -e "$guess is the correct answer!" echo "It took you this may tries: " $count elif [ "$secretNumber" -gt "$guess" …

Member Avatar
Member Avatar
+0 forum 1

Hi~ I've been stuck with this exercise for quite a few days. It's in a book I'm currently self-studying, C++ primer plus. The exercise requires using C syntax, while the exercise which follows this one requires using string objects instead, so i guess this is the appropriate forum^^. It is as follow: [CODE]/* Write a program that uses an array of char and a loop to read one word at a time until the word done is entered. The program should then report the number of words entered (not counting done). A sample run could look like this: Enter words …

Member Avatar
Member Avatar
+0 forum 3

I have a working c file which count lines from a text file. Is there a function that filters out lines with comments(lines started with //)? So when I load in a text file with a c code, it only has to count the lines without comment.

Member Avatar
Member Avatar
+0 forum 2

Hello, I'm new to this thread but have referenced to it before many times. I have finally joined thanks to all the great responses I have read in the past. Okay, I recieved an assignment which is as follow... "Declare a dynamic array of Person to store the information of each student. Implement a simple user interface that allows the enduser of your program to: (1) type in the total number of students at runtime from the keyboard; and (2) provide the specific value of every data member for each student. Then implement the counting sort algorithm to sort all …

Member Avatar
Member Avatar
+0 forum 11

i am writing a program to find all integers that have 5 perfect squares within 30 of them... here is what i have so far: [CODE]#include <iostream> using namespace std; int range[60];//since "within 30" means to more and 30 less void integer(int testInteger) //testInteger is the integer to use to create an array of integers 30 greater than and 30 less than it { int locationInRange = 0;//default for location in the array to be filled in (range[60]) int upperBound = testInteger + 30;//30 more int lowerBound = testInteger - 30;//30 less for (lowerBound; lowerBound <= upperBound; lowerBound++)//"lowerBound" is used …

Member Avatar
Member Avatar
+0 forum 2

The End.