甚至有这样的算法吗? [英] Is there even such an algorith?

查看:100
本文介绍了甚至有这样的算法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道以下算法是否存在:

1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
1.10
1.11
1.12

是否可以通过算法算出这样的数字?

如果Y = 1
而且Val = 1.1
Z = 10

我正在寻找一种算法,例如:
X =(((((Val-Y)* Z)+ 1)/Z)+ Y

但这不可能,因为1.20实际上等于1.2,所以Val必须是我试图避免的字符串.

谢谢,



我已经找到了答案,谢谢.
我一直在寻找的算法是:

If Y = 1
And Val = 1.1
And Z = 10

X = ((((Val - Y) * Z) + 1) / Z) + Y



但是,这不可能,因为1.20等于1.2,而1.30等于1.3.
因此,需要某种形式的字符串处理.

  double 计数器=  0 ;

 double  remWholeNumber =  1 . 0 ;
 double  addWholeNumber =  1 . 0 ;
 double  firstValueInSeq =  1 . 1 ;
 double  remFraction =  10 . 0 ;
 double  addFraction =  10 . 0 ;
 double  X =  0 . 0 ; // 初始化
 double  F =((firstValueInSeq-remWholeNumber)* remFraction);

 for (计数器=  0 . 0 ;计数器<   50 . 0 ;计数器++ )
{
  X = [[F)/addFraction)+ addWholeNumber;
  F ++;

  // 增量计数器
  计数器++;

  printf(" ,X);
} 



//也许现在就说吧?
//我给所有头脑聪明的人打零,以便他们仔细阅读问题.

解决方案

您的意思是:它是否存在一个有限的序列能够重现给定序列的逻辑步骤?"
是的,它存在.


  double  counter =  0 ;

 double  remWholeNumber =  1 . 0 ;
 double  addWholeNumber =  1 . 0 ;
 double  firstValueInSeq =  1 . 1 ;
 double  remFraction =  10 . 0 ;
 double  addFraction =  10 . 0 ;
 double  X =  0 . 0 ; // 初始化
 double  F =((firstValueInSeq-remWholeNumber)* remFraction);

 for (计数器=  0 . 0 ;计数器<   50 . 0 ;计数器++ )
{
  X = [[F)/addFraction)+ addWholeNumber;
  F ++;

  // 增量计数器
  计数器++;

  printf(" ,X);
} 



注意:
这段代码是从算法(我来自哪里的很多数学算法)派生而来的:
如果Y = 1.0
而且Val = 1.1
Z = 10.0

X =((((Val-Y)* Z)+ 1.0)/Z)+ Y

这被放置在我之前删除的解决方案中.
我能够接受自己的回答. (对我来说,这似乎是一个对代码项目的错误)

我的问题的答案是如果要在计算机程序中使用此算法,则不能用数学方法完成,但是可以通过使用字符串操作来完成."

我为什么要说这是我的答案?
因为序列值1.10等于值1.1;当您从1.1开始按顺序进行计数时,每次将1.1递增0.1,则1.9之后的值将是2.0,而不是1.10,这是我希望下一个顺序值成为的值.尚不清楚,因为我们不知道该算法要实现什么.


I''m wondering about whether an algorith exists for the following:

1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
1.10
1.11
1.12

Is it possible to count like this through means of an algorith?

If Y = 1
And Val = 1.1
And Z = 10

I''m looking for an algorithm e.g.:
X = ((((Val - Y) * Z) + 1) / Z) + Y

But this won''t be possible as 1.20 is actually equal to 1.2 so the Val would have to be a string which was what I was trying to avoid.

Thanks,

[EDIT]

I''ve found my answer thank you.
The algorithm which I was looking for is:

If Y = 1
And Val = 1.1
And Z = 10

X = ((((Val - Y) * Z) + 1) / Z) + Y



However, this won''t be possible as 1.20 is equivalent to 1.2 and 1.30 is equivalent to 1.3.
Thus, some form of string manipulation is needed.

double counter = 0;

double remWholeNumber = 1.0;
double addWholeNumber = 1.0;
double firstValueInSeq = 1.1;
double remFraction = 10.0;
double addFraction = 10.0;
double X = 0.0; // initialise
double F = ((firstValueInSeq - remWholeNumber) * remFraction);

for (counter = 0.0; counter < 50.0; counter++)
{
  X = ((F) / addFraction) + addWholeNumber;
  F++;

  // increment counter
  counter++;

  printf("%f\n", X);
}



// Maybe it make sence now?
// I give a zero to all the brainiacs to clever to read the question carefully.

解决方案

Do you mean: "Does it exist a finite sequence of logical steps able to reproduce the given sequence?"
Yes, it exists.


double counter = 0;

double remWholeNumber = 1.0;
double addWholeNumber = 1.0;
double firstValueInSeq = 1.1;
double remFraction = 10.0;
double addFraction = 10.0;
double X = 0.0; // initialise
double F = ((firstValueInSeq - remWholeNumber) * remFraction);

for (counter = 0.0; counter < 50.0; counter++)
{
  X = ((F) / addFraction) + addWholeNumber;
  F++;

  // increment counter
  counter++;

  printf("%f\n", X);
}



NOTE:
This code was derived from the algorith (very much a mathimatical algorithm from where I''m from):
If Y = 1.0
And Val = 1.1
And Z = 10.0

X = ((((Val - Y) * Z) + 1.0) / Z) + Y

This was placed in my previous solution which was deleted.
I was able to accept my own answer. (It looks like a bug to me Code Project)

The answer to my question was that "it cannot be done mathematically however can be done by making use of string manipulation if this algorith were to be used in a computer program."

Why would I say that this is my answer?
Because the sequence value of 1.10 is the equivalent to the value 1.1; When you count sequentially from 1.1 by incrementing 1.1 each time by 0.1, the value after 1.9 would be 2.0 instead of 1.10 which was what I wanted the next sequential value to be.


It''s unclear because we don''t know what the algorithm is trying to achieve.


这篇关于甚至有这样的算法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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