473,388 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

How can-i read integers from a file, where the first line contains unknown elements?

A set of natural numbers is given. Generate all the subsets of this set joined by alternating +and -operators which
sum up to exactly S. .
I/O description. Input: enumeration of elements in the set, on one line, then sum on one line e.g.

1 3 5 7 2 6
0

Output: enumeration of elements resulting in the given sum, e.g.

1-3+2
1+3-6
5-7+2
1+5-6

First i have to read from the file the first line`s elements, could enyone help me?
Dec 9 '10 #1
4 1880
Raj K
9
Read a whole line split it with white space chars. Now you get set of word. Parse each word to get integer.




-RajX
Dec 9 '10 #2
I searched on the internet for many codes, but it does't work. Could you give me some code? How can i read each line, and split them?
Dec 9 '10 #3
johny10151981
1,059 1GB
use fgets function to read line from file

do rest by yourself
Dec 10 '10 #4
i`ve red each line as a string, but now how can-i split it at space characters? any c code? pls
Dec 10 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: lawrence | last post by:
I've waited 6 weeks for an answer to my other question and still no luck, so let me rephrase the question. I know I can do this: <form method="post" action="$self"> <input type="text"...
1
by: Randell D. | last post by:
Folks, I use Apache/PHP with Webazlier to view the log files. I get a number of user agents (web browsers?) that visit the website - For example: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT...
1
by: lawrence | last post by:
What is the PHP equivalent of messaging, as in Java?
7
by: Adams-Blake Co. | last post by:
This may be OT a bit, so maybe someone can point me in the right direction. I want to test a script that sends out an e-mail. I want to test it locally on my Mandrake Linux 8.2 box. It runs OK...
3
by: Anthony Davis | last post by:
Hello all, Can someone please tell me if there is a way to declare variables within a class that can be shared among each new object created from this class? For instance I have the following: ...
3
by: lawrence | last post by:
I do get that MD5() scrambles a password, but how do you then unscrable it? I want to get $password from the user, scrable it, then append it to every link.
8
by: Jeffrey Silverman | last post by:
'nuff said. Just venting... -- Jeffrey D. Silverman | jeffrey AT jhu DOT edu Johns Hopkins University | Baltimore, MD Website | http://www.wse.jhu.edu/newtnotes/
4
by: No | last post by:
I have a php script that I use for a classified site, this script uses field sets that look like this f_dcode|v_255_6|Dealercode||text|||8||||No|No|No|Yes| Is this (field sets) something that...
2
by: DesignGuy | last post by:
I'm trying to get a script to timeout if the server is under heavy load or otherwise unavailable. Eventually, this will try different mirrored domains as each one times out. But at the moment I...
6
by: Michel | last post by:
Hi, I like to build a small simple dinamic website: Point-of-sale (detail-shop), So entering stock, logging all sales, print out invoices and download the logs to be imported into Excel. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.