C#第十六节课
out
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace @out
{
class Program
{
//传值
//传址
public void jia(int x)
{
x = x + 3;
Console.WriteLine("函数里a=" + x);
}
//传值,只将这个变量的值给拿走,不返还,除非return赋值。
//将a的值传入函数,无论这个只在函数中如何变化,不会影响Main中的a变化
//传址,将这个变量的值拿走运算,完成后还是得返还回来(不用return)。
//将a的值传入函数,函数中这个值如何变化,main中的a也会跟着变化
//相当于:函数中的这个值,是main中这个a的快捷方式
//out传值(传址)
public void jia(out int a, out int sum)
{
a = 3;
sum = 5;
sum = sum + a;
a += sum;
}
public void fangcheng(out double x1, out double x2, out double a, out double b, out double c, out double d)
{
d = -1;
x1 = 0;
x2 = 0;
Console.Write("请输入a:");
a = double.Parse(Console.ReadLine());
Console.Write("请输入b:");
b = double.Parse(Console.ReadLine());
Console.Write("请输入c:");
c = double.Parse(Console.ReadLine());
if (a == 0 && b == 0 && c == 0)
{
Console.WriteLine("有无数解");
}
else if (a == 0 && b == 0)
{
Console.WriteLine("无解");
}
else if (a == 0)
{
Console.WriteLine("此为一元一次方程");
x1 = c / b;
x2 = c / b;
}
else
{
d = ((b * b) - (4 * a * c));
if (d == 0)
{
x1 = (-b) / (2 * a);
x2 = (-b) / (2 * a);
Console.WriteLine("此函数只有一个根");
}
else if (d > 0)
{
x1 = ((-b) + Math.Sqrt(d)) / (2 * a);
x2 = ((-b) - Math.Sqrt(d)) / (2 * a);
Console.WriteLine("此函数有两个根");
}
else
{
Console.WriteLine("此函数无解");
}
}
}
static void Main(string[] args)
{
for (; ; )
{
//int a;
//int sum;
Program pp = new Program();
//pp.jia(out a,out sum);
//Console.WriteLine(sum);
//Console.WriteLine(a);
//Console.ReadLine();
double d = 0;
double x1 = 0;
double x2 = 0;
double a = 0;
double b = 0;
double c = 0;
pp.fangcheng(out x1, out x2, out a, out b, out c, out d);
if (d > 0)
{
Console.WriteLine("x1等于:" + x1);
Console.WriteLine("x2等于:" + x2);
Console.WriteLine("a等于:" + a);
Console.WriteLine("b等于:" + b);
Console.WriteLine("c等于:" + c);
}
else if (a == 0 && b != 0 || d == 0)
{
Console.WriteLine("x等于:" + x1);
}
else
{
}
Console.ReadLine();
Console.Clear();
//Program pp = new Program();
//int a = 3;
//pp.jia(a);
//Console.WriteLine("main中a="+a);
//Console.ReadLine();
}
}
}
}
C#第十六节课的更多相关文章
- centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 第三十六节课
centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 ...
- centos linux系统日常管理3 服务管理ntsysv,chkconfig,系统日志rsyslog,last ,lastb ,exec,xargs,dmesg,screen,nohup,curl,ping ,telnet,traceroute ,dig ,nc,nmap,host,nethogs 第十六节课
centos linux系统日常管理3 服务管理ntsysv,chkconfig,系统日志rsyslog,last ,lastb ,exec,xargs,dmesg,screen,nohup,cur ...
- 风炫安全web安全学习第三十六节课-15种上传漏洞讲解(一)
风炫安全web安全学习第三十六节课 15种上传漏洞讲解(一) 文件上传漏洞 0x01 漏洞描述和原理 文件上传漏洞可以说是日常渗透测试用得最多的一个漏洞,因为用它获得服务器权限最快最直接.但是想真正把 ...
- 风炫安全WEB安全学习第二十六节课 XSS常见绕过防御技巧
风炫安全WEB安全学习第二十六节课 XSS常见绕过防御技巧 XSS绕过-过滤-编码 核心思想 后台过滤了特殊字符,比如说
- 风炫安全Web安全学习第十六节课 高权限sql注入getshell
风炫安全Web安全学习第十六节课 高权限sql注入getshell sql高权限getshell 前提条件: 需要知道目标网站绝对路径 目录具有写的权限 需要当前数据库用户开启了secure_file ...
- 《linux就该这么学》第十六节课:第16,17章,Squid服务和iscsi网络存储
第十六章 squid总结: 正向代理:yum 安装后清空防火墙即可正常使用,客户端设置浏览器 透明正向代理:vim /etc/squid/squid.conf 59行:http_port 312 ...
- php第二十六节课
会话购物车 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ...
- php第十六节课
分页 <?php /** file: page.class.php 完美分页类 Page */ class Page { private $total; //数据表中总记录数 private $ ...
- centos shell编程5 LANMP一键安装脚本 lamp sed lnmp 变量和字符串比较不能用-eq cat > /usr/local/apache2/htdocs/index.php <<EOF重定向 shell的变量和函数命名不能有横杠 平台可以用arch命令,获取是i686还是x86_64 curl 下载 第三十九节课
centos shell编程5 LANMP一键安装脚本 lamp sed lnmp 变量和字符串比较不能用-eq cat > /usr/local/apache2/htdocs/ind ...
随机推荐
- [MongoDB]Python 操作 MongoDB
from pymongo import MongoClient mc = MongoClient('localhost',27017) db = mc.users db.users.save({'na ...
- Java API 读取HDFS的单文件
HDFS上的单文件: -bash-3.2$ hadoop fs -ls /user/pms/ouyangyewei/data/input/combineorder/repeat_rec_categor ...
- 【树状数组】POJ 2155 Matrix
附一篇经典翻译,学习 树状数组 http://www.hawstein.com/posts/binary-indexed-trees.html /** * @author johnsondu * @ ...
- JArray获取元素值
MXS&Vincene ─╄OvЁ &0000003 ─╄OvЁ MXS&Vincene MXS&Vincene ─╄OvЁ:今天很残酷,明天更残酷,后天很美好 ...
- Buy or Build (poj 2784 最小生成树)
Buy or Build Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 1348 Accepted: 533 Descr ...
- Mysql查看sql是否走事务
登陆进入server [root@gzmtest_25 ~]# su - mysql [mysql@gzmtest_25 ~]$ mysql.local Welcome to the MySQL mo ...
- thymeleaf+springboot找不到html,只返回了字符串
在浏览器用链接http://localhost:8080/city/page/list 访问时页面上只出现了cityList字样,预期是返回cityList.html 解决:在controller中使 ...
- RPC通信框架——RCF介绍
现有的软件中用了大量的COM接口,导致无法跨平台,当然由于与Windows结合的太紧密,还有很多无法跨平台的地方.那么为了实现跨平台,支持Linux系统,以及后续的分布式,首要任务是去除COM接口. ...
- android有用代码片段
一. 获取系统版本号: [java] view plaincopy PackageInfo info = this.getPackageManager().getPackageInfo(this.g ...
- bzoj 2152 聪聪可可(点分治模板)
2152: 聪聪可可 Time Limit: 3 Sec Memory Limit: 259 MBSubmit: 3194 Solved: 1647[Submit][Status][Discuss ...