鱼C论坛

 找回密码
 立即注册
查看: 3139|回复: 11

请大家帮忙,能看的懂c语言的进

[复制链接]
发表于 2011-9-15 04:07:36 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
我在荷兰学电子工程,老师根本不讲课,第一节课让自己看网页,第二节简单介绍2句,第3节就要展示自己编的程序。我快疯了,根本什么都不会,就要展示。特此向各位大侠求救只要明天8.45前,也就是国内2点45前。编写一个求电阻阴值的程序。别人编好了我抄过来了,请大家指点下,每个部分什么意思,如何改一下
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float R1,R2,R3,R4;
printf("please input R1,R2&R3:");

scanf(" %f",&R1);
scanf(" %f",&R2);
scanf(" %f",&R3);
R4=R1*R2+R2*R3+R1*R3;
printf("Ra=%f \n Rb=%f \n Rc=%f \n",R4/R2,R4/R1,R4/R3);
getch();
}
,用相同的东西替换下。急啊,大家帮帮忙
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2011-9-15 04:36:16 | 显示全部楼层
本帖最后由 ytrfamli 于 2011-9-15 05:20 编辑

#include <????>
include是给编译器看的指令,表示以下这个程序(main)
运作时需要用到<????>档案里头定义的函式*.

*:怎麽把函式打成程序了,晕.更正

printf(????);
printf是指向命令提示符输出一段字串,
在命令提示符上会显示出来.

scanf(????);
scanf是指用一定的格式输入一个数字存起來
这里用%f表示输入数字是浮点数,
这些格式的用法可以用到printf上,
所以底下的printf才会有类似的%f出现.

getch();
通常是用来读取一个字节,例如 char a=getch();
程序就停下来直到键盘上有键被按下,
假设T这个键被按下,那麽a变量里头就存了'T'这个字节
在这里的用处只是让程序停下来而已,
因为在VC中如果用DEBUG调试程序,程序执行到尾巴会自动关闭

>>如何改一下,用相同的东西替换下。
这..如果程序的目的就只有用公式计算几个数字并把结果存起来,
好像没有什麽可以替换的,无非把3个scanf合成一个,
底下printf拆开成好几个之类,好像没有什麽必要
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
 楼主| 发表于 2011-9-15 04:46:05 | 显示全部楼层
非常感谢,但是软件检查出了2个错误。float R1,R2,R3,R4;这个是declaration syntax error
R4=R1*R2+R2*R3+R1*R3;
这个是 undefined symbol ‘R4’ 应该怎么改呢
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2011-9-15 04:57:15 | 显示全部楼层
本帖最后由 ytrfamli 于 2011-9-15 04:58 编辑

float R1,R2,R3,R4;
这是宣告了4个浮点数型变量,可以用来存浮点数据

declaration syntax error
宣告的语法(方式)错误

是不是代码复制贴上时有地方漏了?
我看不出来有什麽错误.用VC编译也没有问题.
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
 楼主| 发表于 2011-9-15 05:00:31 | 显示全部楼层
我用的是borland c++,那我下你那个。不用学校给的了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2011-9-15 06:44:42 | 显示全部楼层
我是来刷墙的

                               
登录/注册后可看大图





















                               
登录/注册后可看大图

孕妇防辐射服有用么
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2011-9-15 08:38:26 | 显示全部楼层
是C++的话,我也找不出来什么不对的哦。。。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2011-9-15 13:44:03 | 显示全部楼层
没错误啊..
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2011-9-15 14:59:55 | 显示全部楼层
主要是题意不明白。。。不知道阁下想要实现什么功能!源程序中的
R4/R1...不知道是为了求什么。。。若是求三电阻并联应该是(R1*R2*R3/R4)....比较费解没搞明白!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2011-9-15 19:59:03 | 显示全部楼层
汗,不就是一个四则运算的实现么…… R1,R2,R3,R4分别代表电阻阻值……
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
 楼主| 发表于 2011-9-18 18:22:32 | 显示全部楼层
1.1         Innetworkanalyses often T T P transformations are used, meaning that anetwork according to figure 1 is being

replaced by an equivalent network according tofigure 2.

file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image002.png









For these transformations the followingformulaes are valid:

file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image004.png            file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image006.png            file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image008.png

Write a program, that, after input of R1, R2 , and R3 computes the values of Ra , Rb and Rc .
"——————————————————————"—————————————————————"

1.2  Writea program, that, after entering of r, L and C computes for an entered frequency in Hz, the
appearent resistant |Z| :
file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image010.png










"——————————————————————"—————————————————————"

1.3  Writea program, that computes the real roots x1 and x2  for the equation  file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image012.png by means of
the abc-formula:  file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image014.png
Input a, b and c .  Take care of asuitable text at input and output. Take care of an error message in
case   b2-4ac  is negative.
"——————————————————————"—————————————————————"

1.4   Write a program, that inputs atemperature in degrees Fahrenheit and that computes this to degrees Celsius.
The formula is:            file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image016.png

Choose proper values to test it anduse suitable texts.


"——————————————————————"—————————————————————"

1.5   Write a program, that computes themaximum voltage U , that can be applied to a resistor R , if that resistor canendure a dissipation P.

                         file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image018.png
            
            Input R and P as positive integersand print Umax , using meaningfull texts.


"——————————————————————"—————————————————————"


2.1          Makea program to simulate the throwing of a dice.
Input a number (integer); accept only numbersin the range 1 to 6.

Example, with 5 as input:
                                    line1:                        XX
                                    line2:                        X
                                    line3:                        XX

Finally print in a loop in sequence thepatterns of line 1, 2 and 3.
The choice of the proper stringconstant for aparticular line is determined by the entered number; thus line2 will give thesame pattern on entering a 3 and/or a 5.

"——————————————————————"—————————————————————"

2.2          Abinary number can be transformed to a decimal value, by multiplying the inputevery time with 2 and (when nescessary) adding 1 to it.
Example, when entering:    100101   à   37   as follows:

            Input                      Decimal            

    1            à            2*  0  + 1 =   1

    0            à            2*  1  + 0 =   2

    0            à            2*  2  + 0 =   4

    1            à            2*  4  + 1 =   9

    0            à            2*  9  + 0 = 18

    1            à            2* 18 + 1 = 37


Write a program, in which the binary number isinputted character after character [use the function:  getche()  ]

and use a while()  to compute the decimal value, until another character than a‘0’ or a ‘1’ is being inputted,

after which the decimal number is printed onthe screen.

"——————————————————————"—————————————————————"

2.3          The  relation between UD and IDis given in the figure  (Diode equation)
file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image020.png
Write a program , that after inputting positivevalues for Uin and R computes the equilibrium, using a while{}using:

            IR- ID  <  1 mAmp.      in the while-condition.

Hint: let, in the while{}  thevoltage UD increase with steps
of 0,1  mV.

Print the thus computed voltage UDand the current ID on the screen.


"——————————————————————"—————————————————————"

2.4          Givenis the next network:

file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image022.pngThe lever of  R2 can move in n steps from top to bottom.
Make aprogram that computes the voltage U1 for every position of thelever.
Print theresults in a table with “headers” : stepnumber and U1 .

Use for thetest for example n=10 , with different combinations
for U, R1 , R2 en R3  .



"——————————————————————"—————————————————————"

2.5          Writea program that asks for an integer input ‘n’ and print all integer numbers of n-digitsfor which the sum of the

digits of the number, to the power of three, isequal to the number itself.

            Forinstance, for n=2, check all numbers in the range of 10 – 99. e.g 37 = 33+73
"——————————————————————"—————————————————————"

3.1          Thevalue of electronic components (resistors, capacitors, etc.) are indicated by a colorcoding,
            using3 colored rings, with the third ring being the (decimal)  multiplication factor:

color            value            mult. factor                        
black                   0                       1                                    Thus  yellow,violet,red means the value  4700  (4k7)
brown                   1                     10
red                   2                   100
orange                   3                       1k                        Writea program, that uses an array of strings
yellow                   4                     10k                        (forthe colors)  and that prints thecolorcoding
green                   5                   100k                        (threerings), after inputting the value.
blue                   6                       1M
violet                   7                     10M
gray                   8
white                   9
"——————————————————————"—————————————————————"
3.2          Writea program, that after the input of a resistance-value, by means of awhile{},  checks if this valueexists
inthe E12 range  (10, 12, 15, 18, 22,27, 33, 39, 47, 56, 68, 82  anddecimal powers until 8,2 Mohm)
Use an array to store this E12 range.
"——————————————————————"—————————————————————"
3.3        Write aprogram to simulate the throwing of a dice.
Input three binary digits  p, q  and  r   (0 or 1),  which together form a binary number pqr.
Print in three statements the face of the dice,giving the value.
file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image023.pngExample:
                                    Inputtedis  011    à  the output will be:            
                                      ( p=0 , q=1 , r=1)


Consider as a model for the dice the following:

file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image024.png


                                                a        b                                                          Then placecrosses            at  a and  g  if   p=1
                                                c   d   e                                                                                    at  b and  f   if  (p | | q) = 1
                                                f        g                                                                                    at  c and  e   if  (p&&q) = 1
                                                                                                                                    at  d             if   r = 1

Hint: make a 3 x 3 array of type char.   Fill this array according to the given formulas and printit.
"——————————————————————"—————————————————————"
3.4        Given isthe following resistance-network:
    file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image026.png
  
  

Make aprogram that computes the replacements resistor R1 for this network,if  n and  R values are being inputted.
To do so,compute:

            Rn   = Rns      + (RBparallel to Rnp ) ,
            Rn-1= R(n-1) s + (Rn parallel to R(n-1) p ) ,
                        :

R2   = R2 s + (R3 parallel to R2p ) ,

                                                                                                                    R1   = R1 s + (R2parallel to R1 p ) .

Input first the “series”-resistances (Ris)and after this the “parallel”-resistances (Rip) and put them in an
array (1 £ i £ n).            Testfor Rip 1 0 .            Testthe program for example with n = 3 and for different values for the
loading resistor RB .
Print the results in a table with “headers”:replacement resistance and load resistance.
"——————————————————————"—————————————————————"
3.5        ALissajou-figure can be constructed by drawing the points in a  xy-plane, with for the x-coordinate the

value: file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image028.png      and forthe y-coordinate the value: file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image030.png  with  file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image032.png

Make a program, that for a number ofcombinations of  l  and  k  (for ex.  1 and 1  ,  1 and 2 , 1and 3  and  1 en 4 )  computes a Lissajou-figure .  Store a, to whole numbers converted, coordinate-pair (i,j)in a  2-dimentional character-arrayby putting a * in the (i,j)-earray-element.  Print after thecomputation the content of the array.
Choose for testing for the parameters thevalues  Tmax = 400,  Ymax = 26  and Xmax = 50  .
"——————————————————————"—————————————————————"

3.6  Abook is missing successive pages. The sum of these page-numbers is being entered and then
the program determines which pages are missing.
One series will do!
"——————————————————————"—————————————————————"


4.1          Your program reads  floatnumbers and during the reading every time the (absolute) biggest number
is printed.  To do so, use a function  Find_max() that from two numbers returns the biggest.
            Theprogram ends after entering the number 0.
"——————————————————————"—————————————————————"

4.2          Your program determines for an entered long number whether or not it isa prime number.

If it is no prime number, the dividers have tobe determined and printed. To do so, use the functions

Prime() , that returns wheather or not it is aprime number and Devider() , that returns a divider of the argument.

"——————————————————————"—————————————————————"

4.3          Your program will, for an entered date, determine the number of dayssince a reference date (Monday , 1-1-1900)
            andit will give the day of the week (Mo, Th, …) for this entered date.
            Usea function Nr_of_days() , returning the number of days since the referencedate.
"——————————————————————"—————————————————————"

4.4          Write a program, that during the entering of  real resistance values prints the average resistance value.

Use a function Average_resistance() , tocompute the average resistance.

"——————————————————————"—————————————————————"

4.5          Write a program, thatafter the entering of a real number x and an integer number n computes the value
            forsin_x , using factoring over n terms. Print  x,  sin_x, sin(x) and the n-th term.
            Usethe functions  Fac() and Term()according to:

            sin_x= Term1 + Term2 + Term3 + …  = x - x3/3! + x5/5! - x7/7! + ….     [ example:  Fac(3) = 1.2.3 ]
"——————————————————————"—————————————————————"

4.6        Write aprogram, that after the entering of a real number x  and an integer number n computes the value

for cos_x , using factoring over n terms.  Print  x,  cos_x,cos(x) and the  n-th term.

            Usethe function Fac() and Term() according to:

            cos_x= Term1 + Term2 + Term3 + …  = 1 - x2/2! + x4/4! - x6/6! + ….    [ example: Fac(3) = 1.2.3 ]
"——————————————————————"—————————————————————"

4.7         Write a program, that after theentering of a real number  x  and a real number  eps (the accuracy) computes
            thevalue for sin_x  (until  |Term(n)|<eps complies) , usingfactoring over  n terms.
            Print  x,  sin_x, sin(x) and the n-th term. Use functions Fac() andTerm() according to:

            sin_x= Term1 + Term2 + Term3 + …  = x - x3/3! + x5/5! - x7/7! + ….     [ example:  Fac(3) = 1.2.3 ]
"——————————————————————"—————————————————————"

4.8         Write a program, that after theentering of a real number x  and areal number  eps (the accuracy)computes
            thevalue for  cos_x  (until  |Term(n)|<eps complies) , using factoring over  n terms.  
            Print  x,  cos_x, cos(x) and the n-th term. Use functions Fac() and Term() according to:

            cos_x= Term1 + Term2 + Term3 + …  = 1 - x2/2! + x4/4! - x6/6! + ….    [ example: Fac(3) = 1.2.3 ]
"——————————————————————"—————————————————————"

4.9         Write a program, that after theentering of a real number x  and aninteger number  n computes
            thevalue for  exp_x  , using factoring over  n terms.  
            Print  x,  exp_x, ex and the n-th term. Use functions  Fac() and  Term() according to:

            exp_x= Term1 + Term2 + Term3 + …  = 1 + x/1! + x2/2! + x3/3! + …. [ example:  Fac(3) = 1.2.3 ]
"——————————————————————"—————————————————————"

4.10            Avoltage source is connected to resistors according to the figure:
  file://localhost/Users/china/Library/Caches/TemporaryItems/msoclip/0clip_image034.png
  

Write a program, that after the entering of  Uin  and  Ro  computes
the voltage  Uout
This computation is done during the entering of  R1, R2, ….Rn.  
Use a function R_parallel(), that returns every time the replacements
resistance for  R1, R2 ….Rn. End the program by entering a negative resistance value.  
Take care of a good user inte**ce
"——————————————————————"—————————————————————"

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
 楼主| 发表于 2011-9-18 18:24:21 | 显示全部楼层
这是这个学期我们要做的,那位大侠给点指导,我一点基础也没有。连PSD都不会画。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-20 21:18

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表