网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
06月28日漏签0天
正德职业技术学院吧 关注:45,737贴子:1,237,592
  • 看贴

  • 图片

  • 吧主推荐

  • 视频

  • 游戏

  • 5回复贴,共1页
<<返回正德职业技...吧
>0< 加载中...

C# 一些小程序分享,不定期更新,有兴趣同学可以自己看看

  • 只看楼主
  • 收藏

  • 回复
  • 刺青锁骨
  • 正德老生
    11
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
3.24
Eg1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Eg1
{
class Program
{
static void Main(string[] args)
{
string userName;
//Console.WriteLine();在命令行打印输出则换行
// Console.WriteLine("请输入你的名字:");
Console.Write("请输入你的名字");//不换行
//将命令行中输入的字符赋值给userName
userName = Console.ReadLine();
Console.WriteLine("你的名字{0}", userName);
Console.ReadKey();
}
}
}
Eg2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Eg2
{
class Program
{
static void Main(string[] args)
{
//一堆数字为 1.1.2.3.5.8.13.21从中找出规律,输入第n个,可求出第n数字为多少
//Boolean bl = true;
//while (bl)
//{
// Console.WriteLine("请输入数字:");
// string number = Console.ReadLine();
// int a = int.Parse(number);
// int b = 1;
// int c = 1;
// int Res = 0;
// if (a == 1 || a == 2)
// {
// Res = 1;
// }
// else
// {
// for (int i = 0; i < a- 1; i++)
// {
// Res = b + c;
// c = b;
// b = Res;
// }
// }
// Console.WriteLine(Res.ToString());
// Console.ReadKey();
//}
Boolean bl = true;
while (bl)
{
Console.WriteLine("请输入数字:");
string number =Console.ReadLine();
int a = int.Parse(number);
int b = 1;
int c = 1;
int Res = 0;
if (a == 1 || a == 2)
{
Res = 1;
}
else
{
int[] arr = new int[a + 1];
arr[0] = 0;
arr[1] = 1;
for (int i = 2; i <= a;i++)
{
arr[i] = arr[i - 1] + arr[i - 2];
Res = arr[i];
}
}
Console.WriteLine(Res.ToString());
Console.ReadKey();
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Eg3
{
class Program
{
static void Main(string[] args)
{
//判断101-200之间有多少素数,并输出所有素数
//for (int i = 101; i <= 200; i++) {
// if (i % 2 == 0) {
// Console.WriteLine("这是素数{0}",i);
// }
//}
//Console.ReadKey();
//int y=101;
//while (y <= 200) {
// if (y % 2 == 0) {
// Console.WriteLine("这是素数{0}",y);
// }
// y++;
//}
//Console.ReadKey();
int[] Ayy = new int[100];
for (int i = 101; i <= 200; i++) {
Ayy[i - 101] = i;
}
foreach (int x in Ayy) {
if (x % 2 == 0) {
Console.WriteLine("这是素数{0}",x);
}
}
Console.ReadKey();
}
}
}


  • 刺青锁骨
  • 正德老生
    11
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Eg4
{
class Program
{
static void Main(string[] args)
{
//水仙花数,如153,1的三次方+5的三次方+3的三次方=153这样的数,为水仙花数
//打印出100-999之间的水仙花数
//int x, j, k;
//Console.WriteLine("水仙数是");
//string s = null;
//for (int i = 101; i <= 1000; i++) {
// s=i.ToString();
// x=s[0]-'0';
// j = s[1] - '0';
// k = s[2] - '0';
// if (i == x * x * x + j * j * j + k * k * k) {
// Console.Write("{0} ", i);
// }
//}
//Console.ReadKey();
// int i, j, k;
// for (int x = 101; x <= 999; x++) {
// i = x / 100;
// j = (x - i * 100) / 10;
// k = (x - i * 100 - j * 10);
// if (x == Math.Pow(i, 3) + Math.Pow(k, 3) + Math.Pow(j, 3)) {
// Console.WriteLine("这是水仙数{0}", x);
// }
// }
// Console.ReadKey();
for (int i = 1; i < 10; i++) {
for (int j = 0; j < 10; j++) {
for(int x=0;x<10;x++){
if (i * 100 + j * 10 + x == i * i * i + j * j * j + x * x * x) {
Console.WriteLine("这是水仙数{0}", i * 100 + j * 10 + x);
}
}
}
}
Console.ReadKey();
}
}
}


2025-06-28 08:46:23
广告
  • Handsame朱先森
  • 难忘母校
    13
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
除了软件专业的能看懂,其他专业的谁会看c#?想学的也都是学c和java啊……几个例子都是大一的时候学的


  • 一条萌萌哒ID
  • 回首昨日
    12
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
也是醉了哎。


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 5回复贴,共1页
<<返回正德职业技...吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示