For, while, do while | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

For, while, do while

Š—Š“рŠ°Š²ŃŃ‚Š²ŃƒŠ¹Ń‚Šµ, тŠ¾Š»ŃŒŠŗŠ¾ Š½Š°Ń‡Š°Š» Š·Š½Š°ŠŗŠ¾Š¼Šøться с ŠæрŠ¾Š³Ń€Š°Š¼Š¼ŠøрŠ¾Š²Š°Š½ŠøŠµŠ¼.Š”тŠ¾Š»ŠŗŠ½ŃƒŠ»ŃŃ с ŠæрŠ¾Š±Š»ŠµŠ¼Š¾Š¹ сŠ²ŃŠ·Š°Š½Š½Š¾Š¹ с цŠøŠŗŠ»Š°Š¼Šø Š² java.Š—Š°Š“Š°Š½ŠøŠµ тŠ°ŠŗŠ¾Šµ: с ŠæŠ¾Š¼Š¾Ń‰ŃŒŃŽ сŠŗŠ°Š½ŠµŃ€Š° сŠæрŠ¾ŃŠøть чŠøсŠ»Š°, (a, b) с чŠµŠ¼ я усŠæŠµŃˆŠ½Š¾ сŠæрŠ°Š²ŠøŠ»ŃŃ Šø Š¾Š±ŃŠŃŠ²Šøть чŠøсŠ»ŠµŠ½Š½Ń‹Š¹ ŠŗŠ¾ŃŃ„Ń„ŠøцŠøŠµŠ½Ń‚ Š¼Š¾Š¶Š½Š¾ Š² ŠŗŠ¾Š½ŃŠ¾Š»Šø, Š½Š¾ тут ŠæрŠ¾Š±Š»ŠµŠ¼Š°, я Š½Šµ Š¼Š¾Š³Ńƒ сŠ¾Š¾Š±Ń€Š°Š·Šøть ŠŗŠ°Šŗ рŠ°ŃŃŃ‡ŠøтŠ°Ń‚ŃŒ суŠ¼Š¼Ńƒ чŠøсŠµŠ» с ŠæŠ¾Š¼Š¾Ń‰ŃŒŃŽ Š²ŃŠµŃ… трŠµŃ… цŠøŠŗŠ»Š¾Š².Š¢Š¾ ŠµŃŃ‚ŃŒ, Šŗ ŠæрŠøŠ¼ŠµŃ€Ńƒ я ŠæрŠøсŠ²Š¾ŠøŠ» Š² ŠŗŠ¾Š½ŃŠ¾Š»Šø Š±ŃƒŠŗŠ²ŠµŠ½Š½Š¾Š¼Ńƒ ŠŗŠ¾ŃŃ„Ń„ŠøцŠøŠµŠ½Ń‚Ńƒ (a) = 1, Š° (b) = 10 - Š½ŃƒŠ¶Š½Š¾, чтŠ¾Š±Ń‹ Š² ŠæрŠ¾Š¼ŠµŠ¶ŃƒŃ‚ŠŗŠµ этŠøх чŠøсŠµŠ» цŠøŠŗŠ»Ń‹ Š²ŃŠµ суŠ¼Š¼ŠøрŠ¾Š²Š°Š»Šø.Š” тŠµŠ¼, ŠŗŠ°Šŗ Š²Ń‹Š²ŠµŃŃ‚Šø рŠµŠ·ŃƒŠ»ŃŒŃ‚Š°Ń‚ Š½Š° эŠŗрŠ°Š½ я сŠæрŠ°Š²Š»ŃŽŃŃŒ, Š° Š²Š¾Ń‚ с цŠøŠŗŠ»Š°Š¼Šø Š½ŠµŠ·Š°Š“Š°Ń‡Š° šŸ¤Æ

7th Jun 2019, 7:58 AM
Lustforknowledge
Lustforknowledge - avatar
5 Respostas
+ 1
I used google translate. If I understand it correct you get two numbers from the user. Can you give an example what you want to do with theese two numbers?
7th Jun 2019, 10:09 AM
Denise RoƟberg
Denise RoƟberg - avatar
+ 1
If you know the number of cycles I would use a for loop: for(int i = 0; i < 3; i++){ sum = sum + (some coefficient) //short: sum += coefficient } If you need a while loop: int cycles = 3; while(cycles > 0){ sum += some coeffient cycles--; }
7th Jun 2019, 11:03 AM
Denise RoƟberg
Denise RoƟberg - avatar
+ 1
Thank you!
7th Jun 2019, 11:05 AM
Lustforknowledge
Lustforknowledge - avatar
0
Yes, you got it right. Thanks to the resulting numbers, you need to calculate the sum of the numbers in the gap with the help of three cycles, in one, as far as I know, this is done with the command sum = sum + (some coefficient)
7th Jun 2019, 10:15 AM
Lustforknowledge
Lustforknowledge - avatar
0
Your welcome :) edit: i < 3 (I changed it in the post)
7th Jun 2019, 11:10 AM
Denise RoƟberg
Denise RoƟberg - avatar