学习C#、net
string s = Console.ReadLine();
int i = Convert.ToInt32(s); //第1种方法
int j = Int32.Parse(s); //第2种方法
Console .WriteLine ("{0},{1}",i,j);
}
}
}
<4>
//(4)编写一个控制台程序,将用户输入的以秒为单位计算的时间长度拆分为以时、分、秒计量,并输出。 using System;
using System.Collections.Generic;
using System.Text;
namespace exercise4
{
class Program
{
static void Main(string[] args)
{
int t = Int32.Parse(Console.ReadLine());
int h = t /3600;
int m = t % 3600 / 60;
int s = t % 60;
Console.WriteLine(t + "秒转换为:");
Console.WriteLine("{0}小时{1}分{2}秒", h, m, s);
}
}
<5>
//(2)编写程序,输出100以内个位数为6且能被3整除的所有的数。
using System;
using System.Collections.Generic;
using System.Text;
namespace exercise
{
class Program
{
static void Main(string[] args)
{
for (int i = 1; i < 100; i++)
if ((i % 10 == 6) && (i % 3 == 0))
Console.WriteLine(i);
}
}
}
<6>
//(1)编写程序,使用if语句将输入的三个整数按从小到大的顺序排序。
using System;
using System.Collections.Generic;
using System.Text;
namespace exercise1
{
class Program
{
C#入门经典第三版文库.txt 第一章 C#语言基础本章介绍C#语言的基础知识,希望具有C语言的读者能够基本掌握C#语言,并以此为基础,能够进一步学习用C#语言编写window...
C入门经典(第4版) 3.1.10 运算符的优先级本章的例子都使用了括号,下面该探讨运算符的优先级了。运算符的优先 级确定了表达式中运算符的执行顺序。运算符包括...
2页 免费 C_需求建模基础与实例 39页 免费 51单片机C语言入门实例 45页 1下载券喜欢此文档的还喜欢 c#实例锦集 38页 免费 C#实例.net_经典例子400... 219页...
机械基础ppt经典 23页 2下载券 PPT_基础_经典_完美_教程... 28页 1下载券...() gives " + c); } } 静态构造函数问题:在Student类的例子中,如果希望...
相同的结果: count = count - 1; count -= 1; --count; C入门经典(第4版) 4.6 再论for循环有了++和– –的更多了解,下面看看另一个使用循环的例子。...
C#入门经典08_IT/计算机_专业资料。C#入门经典C入门经典(第4版) 第08章 程序的结构如第1章所述,将程序分成适度的自包含单元是开发任一程序的基本方式。 当工作...
C入门经典(第4版) 5.1 数组简介说明数组的概念及其作用的最好方法,是通过一个例子,来说明使用数 组后程序会变得非常简单。这个例子将计算某班学生的平均分数 ...
C入门经典(第4版) 2.3.4 变量的初始化在上面的例子,用下面的语句声明每个变量: int Cats; /* The number of cats as pets */ 用下面的语句设定变量Cats...
案例演示: using System; using System.Collections.Generic; using System.Linq;...工作笔记-C#基础 1页 免费 C语言设计经典入门必备笔... 3页 4下载券 Java...
热门文档