效率&&与阵列 [英] efficiency of && vs. array

查看:78
本文介绍了效率&&与阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在处理临床试验的数据。我使用一个名为DataFax的程序编写数据编辑检查

,它有自己的内置编程

语言,它基于C语言,因此,代码示例可能

没有与C完全相同的语法,但原理是一样的。


我正在进行编辑检查,将测试一个一系列的价值观,比如

所以:


if(a == 1&& b == 1&& c == 1& ;& d == 1)

然后....


它发生在我身上,我可以存储a,b,c和d数组和使用

迭代器执行相同的功能:

数字i = 1;

组测试a,b, c,d; / *创建一个名为TEST的数组并存储a,b,c,d

* /

if(condition){

while(i) < = 4){

if(TEST [i] == 1){...;}

i = i + 1;}

然后....


我的问题是:这些方法中的哪一种是最佳做法?是一个

本身比另一个更有效率?我有意义吗?


谢谢,


克里斯



i''m working with data for a clinical trial. i write data edit-checks
using a program called DataFax, which has its own built-in programming
language which is loosely based on C. as such, the code example might
not have the exact same syntax as C, but the principle is the same.

i''m working on a edit check that will test a series of values, like
so:

if (a == 1 && b == 1 && c == 1 && d == 1)
then....

it occured to me that i could store a, b, c, and d in an array and use
an iterator perform the same function:

number i = 1;
group TEST a, b, c, d; /* create an array called TEST and store a,b,c,d
*/
if (condition) {
while (i <= 4) {
if (TEST[i] == 1) {...;}
i = i + 1;}
then....

my question is: which one of these methods is the best practice? is one
inherently more efficient than the other? am i making sense?

thanks,

chris

推荐答案

christopher写道:
christopher wrote:



我正在处理临床试验的数据。我使用一个名为DataFax的程序编写数据编辑检查,该程序有自己的内置编程语言,它基于C语言,因此,代码示例可能没有与C完全相同的语法,但原理是一样的。

我正在进行编辑检查,测试一系列值,如
所以:

if(a == 1&& b == 1&& c == 1&& d == 1)
然后....
它发生在我身上,我可以将a,b,c和d存储在一个数组中并使用
一个迭代器执行相同的功能:

数字i = 1;
组TEST a,b,c,d; / *创建一个名为TEST的数组并存储a,b,c,d
* /
if(condition){
while(i< = 4){
if( TEST [i] == 1){...;}
i = i + 1;}
然后....

我的问题是:这些中的哪一个方法是最好的做法吗?
本身就比其他方法更有效率?我有意义吗?



i''m working with data for a clinical trial. i write data edit-checks
using a program called DataFax, which has its own built-in programming
language which is loosely based on C. as such, the code example might
not have the exact same syntax as C, but the principle is the same.

i''m working on a edit check that will test a series of values, like
so:

if (a == 1 && b == 1 && c == 1 && d == 1)
then....

it occured to me that i could store a, b, c, and d in an array and use
an iterator perform the same function:

number i = 1;
group TEST a, b, c, d; /* create an array called TEST and store a,b,c,d
*/
if (condition) {
while (i <= 4) {
if (TEST[i] == 1) {...;}
i = i + 1;}
then....

my question is: which one of these methods is the best practice?
is one
inherently more efficient than the other? am i making sense?




第一种方式是计算密集度较低。


-

pete



The first way is computationally less intensive.

--
pete


christopher写道:
christopher wrote:
我正在处理临床试验的数据。我使用一个名为DataFax的程序编写数据编辑检查,该程序有自己的内置编程语言,它基于C语言,因此,代码示例可能没有与C完全相同的语法,但原理是一样的。

我正在进行编辑检查,测试一系列值,如
所以:

if(a == 1&& b == 1&& c == 1&& d == 1)
然后....
它发生在我身上,我可以将a,b,c和d存储在一个数组中并使用
一个迭代器执行相同的功能:

数字i = 1;
组TEST a,b,c,d; / *创建一个名为TEST的数组并存储a,b,c,d
* /
if(condition){
while(i< = 4){
if( TEST [i] == 1){...;}
i = i + 1;}
然后....

我的问题是:这些中的哪一个方法是最好的做法?是一个本来就比另一个更有效率的人?我有意义吗?
i''m working with data for a clinical trial. i write data edit-checks
using a program called DataFax, which has its own built-in programming
language which is loosely based on C. as such, the code example might
not have the exact same syntax as C, but the principle is the same.

i''m working on a edit check that will test a series of values, like
so:

if (a == 1 && b == 1 && c == 1 && d == 1)
then....

it occured to me that i could store a, b, c, and d in an array and use
an iterator perform the same function:

number i = 1;
group TEST a, b, c, d; /* create an array called TEST and store a,b,c,d
*/
if (condition) {
while (i <= 4) {
if (TEST[i] == 1) {...;}
i = i + 1;}
then....

my question is: which one of these methods is the best practice? is one
inherently more efficient than the other? am i making sense?




我的建议是编程以获得最大的清晰度。

效率的差异可能微不足道(你知道

优化的三个规则,对吧?)。使用什么表示取决于

变量a,b,c和d来自何处。它们有关系吗?它们有什么关系?

八月


-

我是ILOVEGNU签名病毒。只需将我复制到您的

签名即可。这封电子邮件是根据GNU

通用公共许可证的条款感染的。



My recommendation is to program for maximum clarity. The difference in
efficiency is probably negligible (you know the three rules of
optimization, right?). What representation to use depends on where the
variables a, b, c and d come from. Are they related? How are they related?
August

--
I am the "ILOVEGNU" signature virus. Just copy me to your
signature. This email was infected under the terms of the GNU
General Public License.


不 - 我不知道三条优化规则。它们是什么?

no - i don''t know the three rules of optimization. what are they?


这篇关于效率&amp;&amp;与阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆