Выдается ошибка the name 'k' does not exist in the current context - C#
Формулировка задачи:
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- double m,x;
- int s = 0, t = 0, p = 10;
- Console.Write("m=");
- m = Convert.ToDouble(Console.ReadLine());
- x = m;
- do
- {
- k = x % 10;
- s = p * s + k;
- x = x / 10;
- }
- while (x > 0);
- Console.WriteLine (s);
- }
- }
- }
Решение задачи: «Выдается ошибка the name 'k' does not exist in the current context»
textual
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- double m,x,k;
- int s = 0, t = 0, p = 10;
- Console.Write("m=");
- m = Convert.ToDouble(Console.ReadLine());
- x = m;//получаешь число
- do
- {
- k = x % 10;
- s = Convert.ToInt32(p * s + k);//Кстати тут должно быть так,потому что ты к типу int прибавляешь тип double.
- x = x / 10;
- }
- while (x > 0);
- Console.WriteLine (s);
- }
- }
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д