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();
}
}

最新文章

  1. new 等于 malloc加构造函数
  2. iOS 为iPhone和iPad创建不同的storyboard
  3. iOS.ReactNative-5-make-react-native-to-support-dynamically-update
  4. 全国DNS服务器IP地址【电信、网通、铁通】
  5. VS2013连接不上TFS,TF31002记录
  6. 基于webpivottable做的透视表
  7. Activity之间传递数据或数据包Bundle,传递对象,对象序列化,对象实现Parcelable接口
  8. Scheme Implementations对比
  9. [LeetCode] Pour Water 倒水
  10. AleNet模型笔记
  11. angular和vue的差别
  12. IIS Service Unavailable HTTP Error 503. The service is unavailable.
  13. 基于html2canvas实现网页保存为图片及图片清晰度优化
  14. 抢红包时用到的redis函数
  15. 承接AR定制AR项目外包(正规公司,内附案例)
  16. vue.js的安装
  17. C#-MVC开发微信应用(4)--微信门户菜单的管理操作
  18. Task.Delay() 和 Thread.Sleep() 区别
  19. 开发.Net Script 模板-MyGeneration (翻译)
  20. Mac OS系统 sublime text3 常用快捷键记录

热门文章

  1. 初探计算机网络之HTTPS请求
  2. C#开发BIMFACE系列44 服务端API之计算图纸对比差异项来源自哪个图框
  3. Multidimension Tools(多维工具)
  4. 洛谷3176 [HAOI2015]数字串拆分 (矩阵乘法+dp)
  5. IEEE 754舍入的问题
  6. 对cpu与load的理解及线上问题处理思路
  7. 嵌入式单片机之stm32串口你懂了多少!!
  8. STL模板
  9. 矩阵n次幂的计算
  10. python文件读写及修改