乘法和放大阵列比较;减法 [英] array comparison for multiplication & subtraction
本文介绍了乘法和放大阵列比较;减法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个大的数字(int类型),其被存储在阵列的尺寸至少1000,
我想这两个数字比较,得到的是比其他更大的信息。我怎样才能做到这一点?
其实,我会做两件事情。
- 减去这两个
- 是多重这两(我研究这个话题,的确,我没有找到一个有效的算法,随时帮助我)
解决方案
假设你有一个整数数组
INT标记[1000] = {22,32,12,..............};
首先您排序阵列
INT G,R,C;
为(R = 0;为r = 999; R ++)
{
对于(G = R + 1; G< = 1000; G ++)
{
如果(标记[R]<商标[G])
{
C =标记[R]。 //这3语句交换价值
标记[R] =标记[G]。 //在2细胞被比较
商标[G] = C;
}
}
}
现在你会发现数量最多的是马克斯[0]和第二大的标记[1]
I have two big numbers (type int) which are stored in array with a size at least 1000, and I want to compare these two numbers to get information which one is bigger than the other. How can I do this?
Actually , I will do two things
- subtract these two
- multiply these two (I am studying in this topic, indeed, and I didn't find an efficient algorithm; feel free to help me)
解决方案
Suppose you have an integer array
int Marks[1000]={22,32,12,..............};
First of all you sort your array
int g,r,c;
for ( r=0; r <=999; r++)
{
for ( g=r+1;g<=1000;g++)
{
if ( Marks[r] < Marks[g] )
{
c=Marks[r]; // these 3 statements swap values
Marks[r] =Marks[g]; // in the 2 cells being compared
Marks[g] = c;
}
}
}
Now you find that largest number is Marks[0] and second large is Marks[1]
这篇关于乘法和放大阵列比较;减法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文