using System;
class Program
{
static void Main()
{
Console.WriteLine("请输入两个整数:");
int a = Convert.ToInt32(Console.ReadLine());//Console.ReadLine()默认读取字符串
int b = Convert.ToInt32(Console.ReadLine());//Console.ToInt32()将读到的字符转换为带符号的32位整数
int c = a + b;
Console.WriteLine("两数之和是:" + c);
Console.ReadLine();
}
} using System;
class Program
{
static void Main()
{
short a = 32767;
a = a + (short)1;
Console.WriteLine(a);
}
} using System;
class Program
{
static void Main()
{
int o = sizeof(byte);
int a = sizeof(char);
int b = sizeof(short);
int c = sizeof(int);
int d = sizeof(long);
Console.WriteLine("在32位环境中字节型数所占的字节数为:" + o);
Console.WriteLine("在32位环境中字节型数所占的字节数为:" + a);
Console.WriteLine("在32位环境中字节型数所占的字节数为:" + b);
Console.WriteLine("在32位环境中字节型数所占的字节数为:" + c);
Console.WriteLine("在32位环境中字节型数所占的字节数为:" + d);
}
} Convert.ToInt32("213145");//用Convert类将一个.NET基本数据类型转换成另一个.NET基本数据类型 int a=12345;
string sn=a.ToString();//把a转换成字符串sn
int b=int.Parse(sn);//把sn转换成整数b,结果b=a //数据发生阶段示例
using System;
class Program
{
static void Main()
{
short i = 289;
byte b;
b = (byte)i;
char c = (char)b;
Console.WriteLine("{0}", c);
}
} using System;
class Program
{
static void Main()
{
int a = 12;
a -= a * a;
a += a;
Console.WriteLine("a={0}", a);
}
} using System;
class Program
{
static void Main()
{
bool a = true;
bool b = 5 < 3 && 7 > 4 || 8 > 5;
int c = Convert.ToInt32(a && b);
Console.WriteLine("c={0}", c);
}
}//1 using System;
class Program{
static void Main(){
int a=10,b=20,c=30;
bool m=(a<b&&b>c||a<b);
Console.WriteLine(m);
}
}//true using System;
class Program
{
static void Main()
{
Console.Write("请输入第一个整数:");
int a = Convert.ToInt32(Console.ReadLine());
Console.Write("请输入第二个整数:");
int b = Convert.ToInt32(Console.ReadLine());
int max = a > b ? a : b;
Console.WriteLine("两个整数的较大数是:{0}", max);
}
} using System;
class Program
{
static void Main()
{
bool b1 = false;
Console.Write("请输入第一个数:");
int m = Convert.ToInt32(Console.ReadLine());
Console.Write("请输入第二个数:");
int n = Convert.ToInt32(Console.ReadLine());
b1 = m >= n ? true : false;
Console.WriteLine("结果为:" + b1);
}
} using System;
class Program
{
static void Main()
{
Console.Write("请输入一个整数:");
int x = Convert.ToInt32(Console.ReadLine());
bool m = x > 0 && x <= 100 ? true : false;
Console.WriteLine("{0}", m);
}
} template <class T, class T1 = int, class T2 = int> class A; template<class T, class T1 , class T2 >
class A
{ }; class B: public A<B, int>
{ };
int main(int argc, char* argv[])
{ B b; return 0;
} using System;
class Program
{
static void Main()
{
int a = 240;
int b = -16;
int c = 44;
Console.WriteLine("a={0}右移二位 a={1}", a, a >> 2);
Console.WriteLine("b={0}右移二位 b={1}", b, b >> 2);
Console.WriteLine("c={0}左移二位 c={1}", c, c << 2);
}
} using System;
class Program
{
static void Main()
{
int a = 7, b = 2;
int c = a % b++;
int d = -b;
int e = b / (3 + a);
int f = d + e - c;
Console.WriteLine("f={0}", f);
}
} //十进制,十六进制
using System;
class Program
{
static void Main()
{
int number = 1001;
Console.WriteLine("十进制:{0:1}", number);
Console.WriteLine("十六进制:{0:X}", number);
Console.Write("{0,5}", 25);//三个空格
Console.Write("{0:D5}", 25);//
}
} //talkback.c--一个能为你提供一些信息的对话框
#include<stdio.h> #include<string.h> #define DENSITY 62.4 int main()
{ float weight, volume; int size, letters, m; char name[40]; printf("Hi! What's your first name?\n"); scanf("%s",name); printf("%s, what'syour weight in pounds?\n",name); scanf("%f",&weight); size = sizeof name; letters = strlen (name); volume = weight / DENSITY; printf("well, %s, your volume is %2.2f cubic feet.\n",name, volume); printf("alsso, your first name has %d letters, \n",letters); printf("and we have %d bytes to store it in.\n",size); getchar(); return 0;
} using System;
class Program
{
static void Main()
{
Console.Write("请输入一个年份:");
string str = Console.ReadLine();
int year = Int32.Parse(str);
bool isleapyear = ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0));
string yesno = isleapyear ? "是" : "不是";
Console.WriteLine("{0}年{1}闰年", year, yesno);
}
} using System;
class Program
{
static void Main()
{
Console.Write("请输入一个年份:");
string str = Console.ReadLine();
int year = Int32.Parse(str);
if ((year % 4 == 0) && (year % 100 != 0) || (year % 400) == 0)
Console.WriteLine("{0}年时闰年", year);
else
{
Console.WriteLine("{0}年不是闰年", year);
}
}
} using System;
class Program
{
static void Main()
{
Console.Write("请输入一个整数分数:");
int x = Convert.ToInt32(Console.ReadLine());
if (x > 90)
Console.WriteLine("优秀");
else if (x > 80)
Console.WriteLine("良好");
else if (x > 70)
Console.WriteLine("中等");
else if (x > 60)
Console.WriteLine("及格");
else
Console.WriteLine("不及格");
}
} using System;
class Program
{
static void Main()
{
Console.Write("请输入一个分数:");
string x = Console.ReadLine();
int m = Int32.Parse(x);
int c = m / 10;
switch(c){
case 9:
case 10:Console.WriteLine("优秀");break;
case 8:Console.WriteLine("良好");break;
case 7:Console.WriteLine("一般");break;
case 6:Console.WriteLine("较差");break;
default:Console.WriteLine("差");break;
}
}
} using System;
class Program
{
static void Main()
{
int i = 1, sum = 0;
while(i<=100)
{
sum += 1;
i++;
}
Console.WriteLine("sum={0}", sum);
}
} using System;
class Program
{
static void Main()
{
int digit;
Console.Write("输入一个整数");
string x = Console.ReadLine();
int num = int.Parse(x);
Console.Write("反向显示结果");
while(num!=0)
{
digit = num % 10;
num = num /10;
Console.Write(digit);
}
Console.WriteLine();
}
}

2014年3月5日C#训练的更多相关文章

  1. 马后炮之12306抢票工具(四)--抢票Demo,2014年1月9日终结版

    时隔一年多,终于朋友的忽悠下吧抢票Demo的最后一步完善了,与2014年1月9日成功生成车票. Demo仅经过自己测试,并未在高峰期进行测试,代码质量很差,因为赶工,套用去年模板并未使用设计模式. 代 ...

  2. 无插件的大模型浏览器Autodesk Viewer开发培训-武汉-2014年8月28日 9:00 – 12:00

    武汉附近的同学们有福了,这是全球第一次关于Autodesk viewer的教室培训. :) 你可能已经在各种场合听过或看过Autodesk最新推出的大模型浏览器,这是无需插件的浏览器模型,支持几十种数 ...

  3. 系列文章:老项目的#iPhone6与iPhone6Plus适配#(持续更新中,更新日期2014年10月12日 星期日 )

    本文永久地址为http://www.cnblogs.com/ChenYilong/p/4020399.html ,转载请注明出处. ********************************** ...

  4. 转:[置顶] 从头到尾彻底理解KMP(2014年8月22日版)

    [置顶] 从头到尾彻底理解KMP(2014年8月22日版)

  5. SQLSERVER2014 2014年4月1日发布

    SQLSERVER2014 2014年4月1日发布 原文地址: http://blogs.technet.com/b/microsoft_blog/archive/2014/03/18/sql-ser ...

  6. 千寻浏览器 1.0 Beta 1(524)(2014年5月27日)

    千寻浏览器--又一款新生浏览器今天进入各位浏览迷的视野.千寻浏览器基于IE内核,据传是由百度浏览器的上海团队操刀,在功能定位上,与目前的QQ浏览器有些相似. 千寻来自官方的解释:寻,追寻,探索,又是古 ...

  7. 2014年6月5日 深圳 IBM 安全解决方案会议通知

    2014年6月5日 深圳 IBM 安全解决方案会议通知 http://gdtesting.com/news.php?id=191 时间: 2014年6月5日 地点: 深圳大中华喜来登 议程: IBM安 ...

  8. 09.13日记(2014年9月13日00:18:26)英语,bootstrap,阮一峰,

    我们这里只推荐一本语法书:台湾的旋元佑老师写的<文法俱乐部>(简体版名为<语法俱乐部>).这本书因为出版社倒闭而绝版,淘宝可以买到影印的版本. (1)学英语:奶爸的英语教室 资 ...

  9. 【公告】CSDN个人空间将于2014年4月20日全新改版上线

    尊敬的用户:   你们好!           CSDN个人空间将在2014年4月20日全新改版上线!        CSDN个人空间是2008年8月推出的服务,致力于给广大用户提供在线技术分享和资料 ...

随机推荐

  1. 题解 CF1172E Nauuo and ODT

    题目传送门 题目大意 给出一个 \(n\) 个点的树,每个点有颜色,定义 \(\text{dis}(u,v)\) 为两个点之间不同颜色个数,有 \(m\) 次修改,每次将某个点的颜色进行更改,在每次操 ...

  2. 常用的SQL查询思维/场景

    前言 现在大多数开发工作中,已经可以使用一些组件或框架提供的强大的条件构造器来完成查询数据了,虽然强大而且方便,但也还是存在很多业务场景需要实打实的编写传统SQL语句.特别一些测试.维护.问题排查的时 ...

  3. 【UE4 C++ 基础知识】<9> Interface 接口

    概述 简单的说,接口提供一组公共的方法,不同的对象中继承这些方法后可以有不同的具体实现. 任何使用接口的类都必须实现这些接口. 实现解耦 解决多继承的问题 蓝图使用 使用方法 三种调用方法的区别 调用 ...

  4. 【c++ Prime 学习笔记】第8章 IO库

    C++语言不直接处理输入输出,而是通过标准库中的一组类来处理IO 1.2节介绍的IO库: istream(输入流)类型,提供输入 ostream(输出流)类型,提供输出 cin,是istream对象, ...

  5. [敏捷软工团队博客]Beta阶段发布声明

    项目 内容 2020春季计算机学院软件工程(罗杰 任健) 博客园班级博客 作业要求 Beta阶段发布声明 我们在这个课程的目标是 在团队合作中锻炼自己 这个作业在哪个具体方面帮助我们实现目标 对Bet ...

  6. mysql分表之后怎么平滑上线?

    分表的目的 项目开发中,我们的数据库数据越来越大,随之而来的是单个表中数据太多.以至于查询数据变慢,而且由于表的锁机制导致应用操作也受到严重影响,出现了数据库性能瓶颈. 当出现这种情况时,我们可以考虑 ...

  7. 2021.10.12考试总结[NOIP模拟75]

    T1 如何优雅的送分 考虑式子的实际意义.\(2^{f_n}\)实际上就是枚举\(n\)质因子的子集.令\(k\)为这个子集中数的乘积,就可以将式子转化为枚举\(k\),计算\(k\)的贡献. 不难得 ...

  8. 2021.9.21考试总结[NOIP模拟58]

    T1 lesson5! 开始以为是个无向图,直接不懂,跳去T2了. 之后有看了一眼发现可暴力,于是有了\(80pts\). 发现这个图是有拓扑序的,于是可以用拓扑排序找最长路径.先找原图内在最长路径上 ...

  9. Azure File Storage(一)为本地机器配置网络磁盘

    一,引言 本地机器硬盘空间不够了怎么办?重要文件不想存储在本地硬盘怎么办?加外接移动硬盘:或者换大容量存储设备,都是解决方案.但是每次都得携带,还得考虑当前设备是否支持外接硬盘. 1,这个时候 Win ...

  10. 同人逼死官方系列!基于sddc 协议的SDK框架 sddc_sdk_lib 解析

    基于sddc 协议的SDK框架 sddc_sdk_lib 解析 之前在移植 libsddc 库的时候感觉官方 demo 太低效了( ̄. ̄),复制粘贴代码好累,而且写出一个BUG,其他复制的代码整个就裂 ...