大哥你看这两个程序应该怎么写
Supposethatwehaveafile,profit.in,containingaseriesoflines,eachgivingtheproductcode,quantity,costandpriceofitemssoldinasmallstoreduringaonedayperiod.For
example,101542.052.95
105121.591.98
2301210.870.99
167112.673.98
Theprofitforanitemisquantitytimesthedifferencebetweenpriceandcost.
Writeaprogram,profit.c,whichpromptstheuserforanproductcodethenreadsthrough
thefiletofindtheprofitforthatitem.Theprogramthenprintstheproductcodealong
withtheprofit.Iftheproductcodeisnotpresentinthefilethentheprogramshouldprinta
messagesayingso.
Forexample,iftheinputfileconsistsofthe4linesshownaboveandtheuserentersaproduct
codewhichispresentinthefilethentheprogramoutputmustlooklike:
Enteraproductcode:230
Profitforproduct230is14.52
Enteraproductcode:231
product231isnotfound
就是说读入这个文件中数字来计算但是原来学的都是自己自动比较计算什么的这个user自己输入然后读入文件内容计算应该怎么写好呢
2Writeaprogram,powers.c,whichusesafunction,integerpower,asfollows:
Step1:Readinafloatxandanintegernfromtheuser.
Step2:Callthefunctionintegerpowerwhichcomputesandreturnsx
n.Therearethreecasestoconsider:1)whennispositive,multiplyxbyitselfntimes;(2)whennisnegative,first
multiplyxbyitself|n|times–theresultisthen1.0overtheproduct;andwhenn=0
theresultis1.0.Donotusethefunctionpowfromthemathlibrary
这个题是不是一开始的时候intintergerpower(intn);floatpowers(floatx)只能这么写啊不能两个在一个里面写然后后面的程序用for语句?