C/C++ :: Cannot Count 2D String
Mar 16, 2015
i couldn't count the 2d string. my string is list[100][100] = {"Batuhan","Jeyhun","Tashtanbek"} this is a food line in cafeteria. i want to add a person to this list but i couldnt do it because i dont know the length of my list. it will be more than 3 after i add a person but what if i would add another person after that ? In that case i couldnt be able to tell how long is my line.And after i add people to my list i want to print that list. here is where i came so far:
case 1:
printf("Enter the name of the person to be added
");
printf(">>");
k=0;
[Code].....
View 4 Replies
ADVERTISEMENT
Dec 16, 2014
4.1 Write a program that will count from 1 to 12 and print the count, and its square, for each count.
4.2 Write a program that counts from 1 to 12 and prints the count and its inversion to 5 decimal places for each count. This will require a floating point number.
4.3 Write a program that will count from 1 to 100 and print only those values between 32 and 39, one to a line. Use the incrementing operator for this program.
View 2 Replies
View Related
Dec 20, 2014
I have the codes for such a problem where, to create a program that counts how many times the second string appears on the first string. Yes it counts if you put 1 letter only, but if you put 2, it is an error. As an example. If the first string is Harry Partear, and the second string is ar, it must count as 3. Here's the code:
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main ()
[Code] ....
View 6 Replies
View Related
Dec 16, 2014
This could be non contiguous. As an example
string1: "Hello"
string2: "Heelblloo"
occurrences of string 1 in string2 is 2*3c2*2=12
among 2 e's in string 2, we can select only one and thus 2 possible ways.similarly for l and o.
View 7 Replies
View Related
May 5, 2014
I am creating a program where I count all the letters of the alphabet from a user submitted string.
How would I go about this?
I am completely new, so simplicity is best. I am suppose to use arrays.
View 4 Replies
View Related
Sep 5, 2014
I am writing a program that counts the number of sentences in a string. I count the number of '.' '?' '!'. However, there are Mr. Mrs. PhD. Dr. .
int number_of_sentences = 0;
for(unsigned int i=0; i <= text.length()-1; i++){
if(text[i] == '.' || text[i] == '?' ||text[i] == '!'){
++number_of_sentences;
}
}
return number_of_sentences;
View 3 Replies
View Related
Jul 22, 2013
I'm looking for a program to read a file to look for strings and add a count.
kill.log in the same folder as program
player1 was killed by player2
player2 was killed by player1
4 strings
player1 was for "d1" add count
player2 was for "d2" add count
by player1 for "k1" add count
by player2 for "k2" add count
cout << Player 1 kills: << k1 << deaths << d1;
cout << Player 2 kills: << k2 << deaths << d2;
add up each time.
View 7 Replies
View Related
Sep 2, 2014
I have a upcoming C++ exam. I would like to write a program to convert INDIVIDUAL digits into words.
E.g 678 = six seven eight[/size][/b]
I have the following code:
//Program to print individual digits in words
#include<iostream>
using namespace std;
int main() {
int num;
cout << "Enter a number between 0 and 9999: ";
[Code] ....
View 7 Replies
View Related
Apr 28, 2015
#include <fstream>
#include <iostream>
#include <string>
[Code].....
When I try to run my program I get:
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>C:UsersDocumentsVisual Studio 2010ProjectsCS 111Lab10Lab10DebugLab10.exe : fatal error LNK1120: 1 unresolved externals
What I'm trying to do is get my program to count the number of words in an inputted data file. I've attached the assignment directions
Attached File(s) : lab10_data_.zip (9.27K)
View 4 Replies
View Related
Feb 1, 2014
I wrote a function to count the number of characters in a string. Curious as to why I have to return x-1 and why x isn't the number of characters.
Code:
int count(char *string){
55 int x = 0;
56 char *p;
57 p = string;
58
[Code] .....
View 4 Replies
View Related
Feb 1, 2013
Be given a string of chars, where each single char belongs to the following alphabet: a..zA..Z0..9 (So, in the string there are only lowercases, uppercases and digits. No blank, no comma, ...).
For every char of the given alphabet, count how many times in the string
1----- the char is preceded by its predecessor in the alphabet (consider that the predecessor of 'a' is '9')
2----- the char is followed by its successor in the alphabet (consider that the successor of '9' is 'a')
3----- the char belong to a sequence of identical chars whose length is at least three (i.e.: in the string cc74uyrpfccc348fhsjcccc3848djccccc484jd for three times the character 'c' satisfies this condition)
4----- what is the longest substring of characters strictly rising (the following is greater (>) of the previous)
5----- what is the longest substring of successive characters (i.e.: fhkjshdfruytyzABCDEfglsj => 7)
6----- the frequencies of any char (if in the string the character 'g' occurs 12 times, its frequency is 12)
View 5 Replies
View Related
Feb 3, 2013
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void count();
void main() {
char c[100];
cout<<"Enter a string upto 99 characters(spaces included):"<<endl;
[Code] ....
The thing is, when I don't create a prototype of count and straightaway define it before void main() my program runs, but it gives error in this program that "extra parameter in call to count()" But what to do then?
View 2 Replies
View Related
Sep 20, 2014
I'm trying to create a program that counts the amount of alphabetical characters, numbers, blanks and total amount of characters in a string a user gets to enter. The user also quits the program manually by pressing CTRL + D (in linux terminal).
These are the results I get from the code so far by typing in "hello cplusplus 123 c++" CTRL + D.
The string had:
Alphabetical characters...: 0
Numbers...................: 0
Blanks....................: 3
Total amount of characters: 20
So I can't seem to find a way to count the amount of alphabetical characters and numeric characters.
Here's my code:
#include <iostream>
#include <string>
#include <iomanip>
#include <cctype>
#include <sstream>
using namespace std;
int main() {
string tecken;
[Code] ....
The reason why I declared cctype is that I think I should use the isalpha, isdigit and isblank functions but how I am supposed to do that.
View 1 Replies
View Related
Apr 16, 2013
I am using a for loop to count down from 10 to 0 it's working to count down from 10 to 1 but when the program cames to the 0 then the program freezes by any reason.
Code:
#include <iostream>
using namespace std;
int main()
{
int number[2];
cout << "Enter number: ";
cin >> number[0];
if (number[0] == 1)
[Code] ....
View 11 Replies
View Related
Mar 16, 2013
I'm just trying to find out if the way I've setup my code currently allows me to count the letters as they occur? I don't yet see how to do it but I need clarification. Ideally the function letterCounter would do the counting but atm I'm just trying to figuring it out in the display function.
View 2 Replies
View Related
Feb 12, 2014
I have the following code to print a string to the LCD using my PIC32 Starter Kit; I have made this code work with success. I cannot, however, make the LCD print numbers.
#include<p32xxxx.h>
#define LCD_PRT PORTE //LCD DATA PORT
//#define LCD_DDR DDRE//LCD DDR
//#define LCD_PIN PINE//LCD PIN
[Code].....
I want to change the original code as little as possible, don't worry about my header files - they are fine.
View 2 Replies
View Related
Jul 12, 2013
I am using this code that to check a set of values from a text file and show it on the output.
Code: void MatchNumber(int b) {
vector<Rect> rects;
ifstream theFile("CheckNumber.txt");
double x1,y1,x2,y2;
while(theFile >> x1 >> y1 >> x2 >> y2 ){
rects.push_back(Rect(x1,y1, x2,y2));
}
int num=0;
[code]....
I want to calculate how many times the common number is repeated . So I have used freq[num] in that function. But I am getting the output like this-
Code:
The common number is = 5
The 5 repeated = 1 times
The common number is = 6
The 6 repeated = 1 times
The common number is = 4
The 4 repeated = 1 times
The common number is = 5
The 5 repeated = 1 times
[code]....
So the freq[num] is only returning 1 instead of counting the total number of repeating which is wrong!! I would like to have somthing like this in my output -
Code:
The common number is = 5
The common number is = 6
The common number is = 4
The common number is = 5
The common number is = 5
The common number is = 8
The common number is = 9
The common number is = 6
The common number is = 6
[code]....
How can I do that?
View 3 Replies
View Related
Oct 2, 2013
a sample program using c language on how to count sentences in a paragraph...
View 3 Replies
View Related
Nov 5, 2014
The question is Create a counting program that counts backward from 100 to 1 in increments of 10.
#include <iostream>
using namespace std;
int main() {
int num = 1;
while (num<100) {
[Code] ....
It seems there are some errors.
View 1 Replies
View Related
Nov 13, 2013
I am new to c++. I am writing a program that reads in a text file and gives a count of how many times each letter appeared in the file. I got it to read the text file and do the letter count. B
X = 102
Y = 126
Z = 165
etc...
THAT IS WORNG
The sample output should be
E = 165
T = 126
A = 102
O = 93
etc...
I got it to sort from lowest to highest for the frequency, but cant seem to get the appropriate letter assigned to it.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
[code].....
View 1 Replies
View Related
Jan 22, 2015
iam trying to count the same numbers in an array just once like
38
38
40
38
40
37
the output should be 2 since 38 is repeated and 40 too but for my code the output is 3 thats an example of how it should be in a nutshell i want same number to be counted just once in the whole array
and here's my code :
#include <iostream>
using namespace std;
int main(){
[Code].....
View 11 Replies
View Related
Mar 7, 2013
I have loaded and 1d array from a .dat file, calculated the average of all the numbers. Now I need to count every number in the array that is below the average and cout that number. This is the method in the class I have so far:
int IntegerArray::countBelowAverage(int numBelowAvg) {
avg=IntegerArray::getAvg();
for(int ct=0; ct<avg; ++ct) {
numBelowAvg=ct;
}
return numBelowAvg;
}
My output from this is always 0 and I know that there are numbers below the avg.
View 2 Replies
View Related
Jun 8, 2013
I was coding a program that can count space, new_line, and other characters in a paragraph, but it doesn't work.
#include <stdio.h>
int main(void)
{
[Code].....
View 1 Replies
View Related
Jun 24, 2014
I have a question regarding reference count of an object. How i'll be able to know that how many pointers are pointing to my object.....
View 3 Replies
View Related
Mar 11, 2013
how to put 2 letters together and make them to count as 1?
provided that they must consecutive
for example:
p : count as 0
pxp : count as 0
pp : count as 1
xpxp: count as 0
ppxpp : count as 2
View 1 Replies
View Related
Nov 6, 2014
I want to count values in a struct.
typedef struct {
int x;
int test;
}TYPE_TEST;
TYPE_TEST My[6] ={
{16, 50},
{4, 51},
{50, 52},
{47, 53},
{10, 54},
{19, 55}
};
int Newbuffer[ ????? ]
Now I want to make the size of Newbuffer the sum of all "x", that is 146. Not the size of X.
But how to sum all "x".
View 5 Replies
View Related