キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

Basic Programming Problem

解決済み
解決策を見る

I need to develop a structure on the following condition: where when value of n changes, t should display a value as given below.

 

N ranges from 100 to 1000

T ranges from 35-150

if N>900, T=35

if N>800 and <900, T=40

if N>700 and <800, T=50

if N>600 and <700, T=60

if N>500 and <600, T=70

if N>400 and <500, T=80

if N>300 and <400, T=90

if N>200 and <300, T=120

if N>100 and <200, T=150

0 件の賞賛
メッセージ1/6
3,449件の閲覧回数

Basic answer: use a Case Structure with as many different cases as you need.

Also: your specifications overlooks multiples of 100; what if N = 400, for example?

Once you defined these intermediate cases, you may also divide N by 100 and use the result to index an array containing the output values.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 件の賞賛
メッセージ2/6
3,433件の閲覧回数

I'm very new to this field, can you provide an example?

0 件の賞賛
メッセージ3/6
3,428件の閲覧回数

if n=400 t=80

 

0 件の賞賛
メッセージ4/6
3,416件の閲覧回数
解決策
トピック作成者jtdess5が受理

Personally, I am a fan of using Threshold 1D Array for situations like this.  You get a fractional index, so round down, and then use Index Array to get your T value.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
メッセージ5/6
3,414件の閲覧回数

Thank you for helping me

0 件の賞賛
メッセージ6/6
3,409件の閲覧回数