(1)试求i1,i2,i3,i4,i5,i6,i7,i8的值;(2)由(1)推测in(n∈N*)的值有什么规律,并用式子表

作者&投稿:塔彼 (若有异议请与网页底部的电邮联系)
C#怎么在一组数里选出最小值 我现在有i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12 我要从里面选出最小值的数~

int[] i = new int[12]{i1,i2......i12};
for (int j=0;j<i.lengh-1;++j)
{
if (i[j]<i[j+1])
{
i[j+1] = i[j];
}
}
最好得到的i[11]就是最小值

#include
#include
#include
#include
#include
#include
#include

using namespace std;

class Equation
{
public :

/*
假设所有合法的表达式的计算结果都是正数
如果预见表达式重复,返回 REPEAT_EXPRESSION
例如 :
123 + 456 和 456 + 123 重复
123 * 456 和 456 * 123 重复
*/
static const int REPEAT_EXPRESSION = -1;

static int calculate(string equation);
static int calculateFunction(int numA,char op,int numB);
static bool isOperator(char op);
static int getOperatorRank(char op);
static bool isExchengeableOperator(char op);

Equation(string pattern,string digitSet);
void printMatchResult();
private :
void match();
void matchFunction(bool isDigitUsed[],int startMatchPos);
// 等式的模式
string pattern;
// 替换等式中数字的数字集合
string digitSet;
// 替换后成立的等式结果
vector matchResult;
};

Equation :: Equation(string pattern,string digitSet)
{
this->pattern = pattern;
this->digitSet = digitSet;
this->match();
}
// 输出结果
void Equation:: printMatchResult()
{
cout pattern <<endl;
for(int i = 0 ; i matchResult.size(); i ++)
{
cout.width(4);
cout << (i+1) << " : ";
cout matchResult[i] << endl;
}
}

void Equation :: match()
{
// 递归函数 matchFunction 需要的参数
bool* isDigitUsed = new bool[this->digitSet.size()];
for(int i = 0 ; i digitSet.size() ; i ++ )
{
isDigitUsed[i] = false;
}
matchFunction(isDigitUsed,0);
free(isDigitUsed);
}
/*
将 this->pattern 中的数字用 this->digitSet 中的数字替换
得到一个所有替换后的表达式。

如果表达式成立,结果保存在 this-> matchResult 中
*/
void Equation :: matchFunction(bool isDigitUsed[],int startMatchPos)
{
if(startMatchPos == this->pattern.size())
{
string leftExpression = this->pattern.substr(0,this->pattern.find('=')) ;
string rightExpression = this->pattern.substr(this->pattern.find('=') + 1) ;

// cout << leftExpression << " = " << calculate(leftExpression) << " , "
// << rightExpression << " = " << calculate(rightExpression) << endl;

try
{
int leftExpressionValue = calculate(leftExpression);
int rightExpressionValue = calculate(rightExpression);
if( leftExpressionValue == rightExpressionValue &&
!(leftExpressionValue == REPEAT_EXPRESSION || rightExpressionValue == REPEAT_EXPRESSION ))
{
this->matchResult.push_back(this->pattern);
}
}
catch(string & msg)
{

}

return;
}


if(this->pattern.at(startMatchPos) == 'o')
{
for(int digitPoint = 0 ; digitPoint digitSet.size(); digitPoint ++)
{
if(!isDigitUsed[digitPoint])
{
// 标记
this->pattern.at(startMatchPos) = this->digitSet.at(digitPoint);
isDigitUsed[digitPoint] = true;
// 递归
matchFunction(isDigitUsed,startMatchPos + 1);
// 回溯
isDigitUsed[digitPoint] = false;
this->pattern.at(startMatchPos) = 'o';
}
} // end for( digitPoint )
}

else
{
matchFunction(isDigitUsed,startMatchPos + 1);
}

}
// 判断是否是操作符
bool Equation :: isOperator(char op)
{
if(op == '+' || op == '-' || op == '*' || op == '/' || op == '@')
{
return true;
}
else
{
return false;
}
}

// 操作数可以左右互换的运算符
bool Equation :: isExchengeableOperator(char op)
{
if(op == '+' || op == '*' )
{
return true;
}
else
{
return false;
}
}

// 获取各种运算符的优先级
int Equation :: getOperatorRank(char op)
{
if(op == '+' || op == '-' )
{
return 0;
}
else if( op == '*' ||op == '/')
{
return 1;
}
else if(op == '@')
{
return -1;
}
}
// 计算简单表达式,只有一个运算符
int Equation :: calculateFunction(int numA,char op,int numB)
{
if(op == '+')
{
return numA + numB;
}
else if(op == '-')
{
return numA - numB;
}
else if(op == '*')
{
return numA * numB;
}
else if(op == '/')
{
return numA / numB;
}
}

// 计算复杂表达式 equation 的值
int Equation :: calculate(string equation)
{
stack operators;
stack data;

int preOperatorPos = -1;
equation.append("@");

for(int i = 0 ; i < equation.size() ; i ++)
{
if( isOperator(equation.at(i)) )
{
// 字符串形式的整数
string dataString = equation.substr(preOperatorPos+1).substr(0,i-preOperatorPos-1);
// 将字符串装换成整数,并放入
data.push(atoi(dataString.c_str()));

// 连续从【运算符栈中】取出优先级比【当前读到】的运算符大的运算符

while(operators.size() > 0 && getOperatorRank(equation.at(i)) <= getOperatorRank(operators.top()))
{
char op = operators.top();
operators.pop();
int numB = data.top();
data.pop();
int numA = data.top();
data.pop();

if( ((int)log10(numA)) == ((int)log10(numB)) && isExchengeableOperator(op) && numA > numB)
{
return REPEAT_EXPRESSION;
}
data.push(calculateFunction(numA,op,numB));
}

operators.push(equation.at(i));
preOperatorPos = i;
}
}
return data.top() ;
}

int main(int argc, char *argv[])
{
Equation e1 = Equation("ooo+ooo=ooo","123456789");
e1.printMatchResult();

Equation e2 = Equation("o*oooo=oooo","123456789");
e2.printMatchResult();

Equation e3 = Equation("oo*ooo=oooo","123456789");
e3.printMatchResult();

Equation e4 = Equation("o*ooo=oo*ooo","123456789");
e4.printMatchResult();

Equation e5 = Equation("o*ooo=o*oooo","123456789");
e5.printMatchResult();

Equation e6 = Equation("oo*oo=oo*ooo","123456789");
e6.printMatchResult();
return 0;
}
/*
运行结果:
pattern:ooo+ooo=ooo
1 : 124+659=783
2 : 125+739=864
3 : 127+359=486
4 : 127+368=495
5 : 128+367=495
6 : 128+439=567
7 : 129+357=486
8 : 129+438=567
9 : 129+654=783
10 : 129+735=864
11 : 134+658=792
12 : 135+729=864
13 : 138+429=567
14 : 138+654=792
15 : 139+428=567
16 : 139+725=864
17 : 142+596=738
18 : 142+695=837
19 : 143+586=729
20 : 145+692=837
21 : 146+583=729
22 : 146+592=738
23 : 152+487=639
24 : 152+784=936
25 : 154+629=783
26 : 154+638=792
27 : 154+782=936
28 : 157+329=486
29 : 157+482=639
30 : 158+634=792
31 : 159+327=486
32 : 159+624=783
33 : 162+387=549
34 : 162+783=945
35 : 163+782=945
36 : 167+328=495
37 : 167+382=549
38 : 168+327=495
39 : 173+286=459
40 : 173+295=468
41 : 175+293=468
42 : 176+283=459
43 : 182+367=549
44 : 182+394=576
45 : 182+457=639
46 : 182+493=675
47 : 182+754=936
48 : 182+763=945
49 : 183+276=459
50 : 183+492=675
51 : 183+546=729
52 : 183+762=945
53 : 184+392=576
54 : 184+752=936
55 : 186+273=459
56 : 186+543=729
57 : 187+362=549
58 : 187+452=639
59 : 192+384=576
60 : 192+483=675
61 : 192+546=738
62 : 192+645=837
63 : 193+275=468
64 : 193+482=675
65 : 194+382=576
66 : 195+273=468
67 : 195+642=837
68 : 196+542=738
69 : 214+569=783
70 : 214+659=873
71 : 215+478=693
72 : 215+748=963
73 : 216+378=594
74 : 216+738=954
75 : 218+349=567
76 : 218+376=594
77 : 218+439=657
78 : 218+475=693
79 : 218+736=954
80 : 218+745=963
81 : 219+348=567
82 : 219+438=657
83 : 219+564=783
84 : 219+654=873
85 : 234+657=891
86 : 235+746=981
87 : 236+718=954
88 : 236+745=981
89 : 237+654=891
90 : 238+419=657
91 : 238+716=954
92 : 239+418=657
93 : 241+596=837
94 : 243+576=819
95 : 243+675=918
96 : 245+673=918
97 : 245+718=963
98 : 245+736=981
99 : 246+573=819
100 : 246+591=837
101 : 246+735=981
102 : 248+319=567
103 : 248+715=963
104 : 249+318=567
105 : 251+397=648
106 : 254+619=873
107 : 254+637=891
108 : 257+391=648
109 : 257+634=891
110 : 259+614=873
111 : 264+519=783
112 : 269+514=783
113 : 271+593=864
114 : 271+683=954
115 : 273+546=819
116 : 273+591=864
117 : 273+645=918
118 : 273+681=954
119 : 275+418=693
120 : 275+643=918
121 : 276+318=594
122 : 276+543=819
123 : 278+316=594
124 : 278+415=693
125 : 281+394=675
126 : 281+673=954
127 : 283+671=954
128 : 284+391=675
129 : 291+357=648
130 : 291+384=675
131 : 291+546=837
132 : 291+573=864
133 : 293+571=864
134 : 294+381=675
135 : 296+541=837
136 : 297+351=648
137 : 314+658=972
138 : 317+529=846
139 : 317+628=945
140 : 318+627=945
141 : 318+654=972
142 : 319+527=846
143 : 324+567=891
144 : 324+657=981
145 : 327+519=846
146 : 327+564=891
147 : 327+618=945
148 : 327+654=981
149 : 328+617=945
150 : 329+517=846
151 : 341+586=927
152 : 342+576=918
153 : 346+572=918
154 : 346+581=927
155 : 352+467=819
156 : 354+618=972
157 : 354+627=981
158 : 357+462=819
159 : 357+624=981
160 : 358+614=972
161 : 362+457=819
162 : 364+527=891
163 : 367+452=819
164 : 367+524=891
165 : 372+546=918
166 : 376+542=918
167 : 381+546=927
168 : 386+541=927
pattern:o*oooo=oooo
1 : 4*1738=6952
2 : 4*1963=7852
pattern:oo*ooo=oooo
1 : 12*483=5796
2 : 18*297=5346
3 : 27*198=5346
4 : 28*157=4396
5 : 39*186=7254
6 : 42*138=5796
7 : 48*159=7632
pattern:o*ooo=oo*ooo
1 : 4*897=23*156
2 : 7*538=14*269
3 : 7*586=14*293
4 : 7*638=29*154
5 : 7*658=14*329
6 : 7*984=56*123
7 : 8*459=27*136
8 : 8*759=46*132
9 : 9*476=28*153
10 : 9*534=18*267
11 : 9*546=18*273
12 : 9*654=18*327
13 : 9*782=46*153
pattern:o*ooo=o*oooo
1 : 4*679=2*1358
2 : 4*769=2*1538
3 : 4*793=2*1586
4 : 6*583=2*1749
5 : 6*729=3*1458
6 : 6*792=3*1584
7 : 6*927=3*1854
8 : 7*534=2*1869
9 : 7*986=2*3451
10 : 8*394=2*1576
11 : 8*439=2*1756
12 : 8*459=1*3672
13 : 8*469=1*3752
14 : 8*537=1*4296
15 : 8*579=1*4632
16 : 8*592=1*4736
17 : 8*674=1*5392
18 : 8*679=1*5432
19 : 8*742=1*5936
20 : 8*794=1*6352
21 : 8*932=1*7456
22 : 8*942=1*7536
23 : 8*953=1*7624
24 : 8*954=1*7632
25 : 9*582=3*1746
26 : 9*638=1*5742
27 : 9*647=1*5823
28 : 9*836=1*7524
pattern:oo*oo=oo*ooo
1 : 46*79=23*158
2 : 54*69=27*138
3 : 54*93=27*186
4 : 58*67=29*134
5 : 58*69=23*174
6 : 58*73=29*146
7 : 58*96=32*174
8 : 63*74=18*259
9 : 64*79=32*158
10 : 73*96=12*584
11 : 76*98=14*532
*/

(1)i1=i,i2=-1,i3=i2?i=-i;i4=(i22=(-1)2=1,i5=i4?i=i,i6=(i23=(-1)3=-1,i7=i6?i=-i,i8=(i42=1,…
(2))∵i1=i,i2=-1,i3=i2?i=-i;i4=(i22=(-1)2=1,
从n=1开始,4个一次循环.
∴i4n=1,i4n+1=i,i4n+2=-1,i4n+3=-i(n为自然数),
(3)由于2012=4×503,
∴i2012的值=1.




已知电阻R1、R2相并联,R1=4KΩ,R2=2KΩ,I=60mA,求I1、I2
1\/R=1\/R1+1\/R2,可求出R=4\/3KΩ,再由U=IR=80V,因为U=U1=U2,则I1=U\/R1=20mA,I2=U\/R2=40mA.

大学物理电路:使用叠加定理求I1,I2,I3(我做错了,必须用叠加定理做)?
6v单独作用时,i1'=6\/[1020+(510并1330)],i2'=-i1' x 510\/1840,i3'=i1'+i2';12v单独作用时,i2"=12\/[1330+(510并1020)],i1"=-i2" x 1\/3,i3"=i2" x 2\/3。

电路如题2-18图所示,试用节点电压法求I1和I2
V1 - V2 = Us 解出方程:I1 = V1 \/ 18 I2 = V2 \/ 4 节点电压法是以流入节点的电流代数和为零列方程的,基本规则如下:自电导之和乘以节点电压,减去互电导乘以相邻节点电压,等于流入节点的电源电流代数和。自电导:只要电阻的一端在节点上,电阻的倒数就是电导。互电导:电阻连接在两个...

如图所示直流电源电路中,试求开关S断开时电路各段I1 I2 I3 (2)S闭合...
当S断开,R1 R2 R3 R 串联,I1=I2=I3=E\/(R1+R2+R3+R)= 2A 当S闭合,R1 R3 R 串联, R2 短路 I2=0 IS=E\/(R1+R3+R)=4A U=IR=4V U1=IR1=96V U2=0V U3=IR3=120V

...Ia=Ib=1A,R1=1Ω,R2=2Ω,R3=3Ω,试求电流I1、I2、I3和Ic
根据KCL,那么有IA+IB+IC=0,所以IC=-2A 又,I1+IA=I2 ...(1)I2+IB=I3...(2)I1R1+I2R2+I3R3=0...(3)可以解出: I1=-4\/3 A I2=-1\/3 A I3=2\/3 A

、1、如图所示电路中的电流I1和I2各为多少? (7分)
选取流出节点为正向,由KCL:i1+5-3=0;i2-8-2-i1=0;解得 i1=-2A;i2=8A。

...VD3的正向导通电压均为0.7v,试求电路中电流I1、I2、I3
1000 I3 =2.1 , I3 = 2.1\/1000 =2.1mA 6-2.1= 560 I1 , I1 =3.9\/560 = 6.96mA I2 = I1 - I3 = 4.86mA

...R2=5Ω ,R3=6 Ω ,试求图中的电流I1,I2 和I3
I2=6A I3=10A (2)设左边的网孔的回路方向为顺时针,右边的网孔的回路方向为逆时针 根据基尔霍夫第一定律ΣI入=ΣI出可知 I1+I2=I3 根据基尔霍夫第二定律ΣE=ΣIR可知 对于左边的网孔:I1*R1+I3*R3=E1 对于右边的网孔:I2*R2+I3*R3=E2 代入已知数得 I1+I2=I3 (A)20*...

两道题求大神帮解! 图1 电路如图所示,求I1和I2的大小! 图2 根据图2所...
第一题:I1=11A,方向向右 I2=33A,方向向右 第二题:周期10S,频率0.1Hz 最大值25根号2V,有效值25V 25根号2sin(w0)=20,w0=arcsin(2\/5根号2)

...在t=0时将开关由1投向2。试求t=0瞬间的i1、i2、iD的初始值。_百度知...
阶电路用三要素 iL(0)=-6\/5 A iL(∞)=+6\/5 A 间数 T=9\/5 s 所iL(t)=(-6\/5-6\/5)e^(-5t\/9)+6\/5 A

义马市13845292610: 直流电路如图所示,试用叠加原理求各电阻支路中的电流 I1、I2、I3、I4 -
柳保热淋: 电流源单独作用时,电流源从 C 点流出,经R1 、R2 反比例分流,汇集与 4 个电阻的公共点 A (D),再经 R3、R4分流,回到 B 点,要注意各个支路电流方向. I1 = - 7 * R2 / (R1+R2) = - 7 * 10 / 14 = - 5 A I2 = 2 A I3 = 7 * R4 / (R3+R4) = 7 * 8 / 14 = 4 A I4 = - 3 A 电压源单独作用: I1 = I2 = E / (R1+R2) = 1 A I3 = I4 = E / (R3+R4) = 1 A 合并电流: I1 = - 4 A I2 = 3 A I3 = 5 A I4 = - 2 A

义马市13845292610: 求i1、i2、i3、i4 -
柳保热淋: 直接列kcl、kvl方程就可以算出:i1+i2=12-i1+2i2+6i3+24=0-24-6i3+6i4=0 i3+i4=i2 解得:i1=12 i2=0 i3=-2 i4=2

义马市13845292610: 用等效变换的方法,求所示电路中电流i1,i2,i3,i4 -
柳保热淋: 解:保留I1所在支路不参与变换,从右侧开始.4V电压源串联5Ω电阻,等效为4/5=0.8A电流源(向上)、并联5Ω电阻;2A电流源逆向并联0.8A电流源,等效为2-0.8=1.2A电流源(向下);1.2A电流源并联5Ω电阻,等效为1.2*5=6V电压源(下...

义马市13845292610: 如图电路所示,求电流I1,I2,I3,I4,I5,要过程,谢谢! -
柳保热淋: 本题如用支路电流法,则需要列解六元一次方程组,手工很难完成. 用网孔电流法. I2=I0-I1 I4=I0-I3 I5=I3-I1 只要在所画三个网孔列三个方程解出I0、I1、I3)即可 R1I1+R5(I1-I3)+R2(I1-I0)=0 R3I3+R4(I3-I0)+R5(I3-I1)=0 R2(I0-I1)+R4(I0-I3)=U 化...

义马市13845292610: 物理题目跪求解答求电流i1 i2 i3 i4 i5有没有大神? -
柳保热淋: 总有效电阻10Ω 所以I1=2.4A I2=I4=1.2A I3=I5=0.6A

义马市13845292610: 求各支路I1,I2,I3,I4,I5的电流? -
柳保热淋: i1=i4,i2=i5;i3=i1+i2 ..................(1) 10=(R1+R4)i1+i3R3 .........(2),5=(R2+R5)i2+i3R3 ...........(3),解方程就可以.

义马市13845292610: 如图电路所示,求电流I1,I2,I3,I4,I5,  要步骤,或提示一下方法 -
柳保热淋:[答案] 本题如用支路电流法,则需要列解六元一次方程组,手工很难完成. 用网孔电流法. I2=I0-I1 I4=I0-I3 I5=I3-I1 只要在所画三个网孔列三个方程解出I0、I1、I3)即可 R1I1+R5(I1-I3)+R2(I1-I0)=0 R3I3+R4(I3-I0)+R5(I3-I1)=0 R2(I0-I1)+R4(I0-I3)=U 化简 (R1+R...

义马市13845292610: 六元一次方程组求解 I1.I2.I3.I4.I5.I6 在线等,挺急的 -
柳保热淋: i1 -> 24/11, i2 -> 6, i3 -> 30/11, i4 -> 36/11, i5 -> 12/11, i6 -> -(42/11)

义马市13845292610: 请问i1 i2 i3 是怎么得出来的 -
柳保热淋: 箭头后两式相加,除以7,i1十i3=10 第一式,is2=6A,代入 i1十6=i3 相减 i3-6=10-i3 2i3=16 i3=8

义马市13845292610: 2 - 13 求图2 - 38所示电路中的支路电流I1,I2、I3、I4、I5. -
柳保热淋: 1.先算总的电阻 R1=2*1/(2+1)=2/3 R2=(R1+1)*1/(R1+1+1)=5/8 R总=R2+1=13/82.算总电流I1 I1=10/R总=6.15 3.算I2 I3 I4 I5 I2=(10—6.15*1)/1=3.85 I3=I1-I2=2.3 I4=(3.85-2.3*1)/1=1.55 I5=I3-I4=0.75 亲 注意加点位哈

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网