作者kikiqqp (貓食罐頭)
看板C_and_CPP
標題Re: [問題] c語言程式求助
時間Tue Oct 13 21:35:16 2009
※ 引述《ddavid (謊言接線生)》之銘言:
: ※ 引述《csihcs (非天夜翔)》之銘言:
: : VBA 版
: : Dim kg As String
: : kg = InputBox("輸入體重 KG ?")
: : MsgBox (kg + " KG = " + CStr(Val(kg) / 0.454) + "磅")
: C# 版
: using System;
: namespace ConsoleApplication1
: {
: class Program
: {
: static void Main(string[] args)
: {
: Console.WriteLine((Convert.ToDouble(Console.ReadLine()) /
: 0.45359237).ToString() + " pounds");
: }
: }
: }
一樣C#版
不過用新手寫法
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter your weight(kg):");
float wei = float.Parse(Console.ReadLine());
Console.WriteLine( " {0} kg = {1} lb", wei, wei / 0.454 );
}
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.116.119.110
推 ddavid:其實除了我把它黏成一行外,我不知道用Parse還是Convert比 10/13 21:37
→ ddavid:較新手耶XD 10/13 21:37
→ VictorTom:=A1/0.454 這Excel版的XD 10/13 21:55
→ VictorTom:我本來想畫圖的, 可是不會畫, 在公司畫這個會被打死Orz 10/13 21:55
推 liu2007:你可以劃一大堆格子,上面有一個長方格 裡面鑲這個算式 10/13 21:57
→ liu2007:然後表格的某一格是公斤的數字 10/13 21:57
→ csihcs:剛剛還想PO~~EXCEL版的說~~哈哈 10/13 21:57
→ VictorTom:樓上你可以改畫小算盤版的啊....XD 10/13 21:59
→ csihcs:還小算盤版的唷XDDDDD 10/13 22:11