struct vector3
{
double x;
double y;
double z;
double xianliang=(x*x+y*y+z*z);
}
struct vector3
{
double x;
double y;
double z;
double xianliang=(x*x+y*y+z*z);
}
Console.WriteLiine("Helllo World!");

勾选这两项就有控制台应用程序了
con
单行注释和多行注释
快捷键注释ctrl+kctrl+c 取消注释ctrl+kctrl+u
2、一行一条语句,语句的结束加上;
3、代码块0
4、程序执行顺序
5、如何执行(快捷键)
6输出的两个方法Write和WriteLine
练习题1-判断对错
1//我是注释!
2W我是注释!
3//我是注释!
4/*我是注释*/
5\*我是注释 "
6/*我是注释*/
一般编译 :
高级语言(C语言)~机器语言(0101)
c#编译
代码~程序集(exe dll)
convert.toint32(字符串)
作用:将整数字符串转化为整数类型
'12'->12
如果想要控制台显示结果,需要加上语句
Console.ReadKey();
注释快捷键
ctrl K ctrl c
取消注释
ctrl K ctrl u
C#基本语法 菜鸟教程,查转译等基础讲解
“\”会转译后面的字符,如果想要输出“\”则使用\\
tab:\t
注释快捷键:选中要改为注释的部分,ctril+k ctrl+c
取消注释:选中,ctrl+k ctrl+u
命名空间包含类,类包含方法
Ctrl+k +1 ctrl+c加注释
2Ctrl +u去掉注释
int a = 0;
while (a++<100&&a++%2==1)
{
Console.WriteLine(a);
}
int n1 = Convert.ToInt32(Console.ReadLine());
int n2 = Convert.ToInt32(Console.ReadLine());
int a = 0;
while (n1<=n2)
{
a = n1++;
if (a % 2 == 0)
{
Console.WriteLine(a);
}
}
话
using System;
namespace ConsoleApp3
{
internal class Program
{
static void Main(string[] args)
{
string str = "aateu";
int[] countarr = new int[26];
for (int i = 0; i < str.Length; i++)
{
countarr[str[i] - 'a']++;
}
for(int i=0; i<countarr.Length;i++)
{
Console.WriteLine($"{(char)(i+'a')}={countarr[i]}");
}
}
}
}
using System;
namespace ConsoleApp3
{
internal class Program
{
static void Main(string[] args)
{
string str = "arateu";
int[] countarr = new int[26];
for (int i = 0; i < str.Length; i++)
{
countarr[str[i] - 'a']++;
}
for(int i = 0;i < str.Length; i++)
{
if (countarr[str[i] - 'a'] == 1) {
Console.WriteLine(str[i]);
break;
}
}
}
}
}
using System;
namespace ConsoleApp3
{
internal class Program
{
static void Main(string[] args)
{
int[] intArray = { 12, 2, 33, 5, 51, 6 };
for (int i = 0; i < 2; i++) {
for (int j=0;j<intArray.Length-i-1;j++) {
if (intArray[j] > intArray[j+1]) {
int temp=intArray[j+1];
intArray[j+1]=intArray[j];
intArray[j]=temp;
}
}
}
//foreach (int i in intArray) {
// Console.Write(i+" ");
//}
Console.WriteLine(intArray[intArray.Length-2]);
}
}
}
using System;
namespace ConsoleApp3
{
internal class Program
{
static void Main(string[] args)
{
int[] intArray = { 12, 72, 33, 5, 51, 6,65 };
int max1=0,max2=0;
for (int i = 0; i < intArray.Length; i++) {
if (intArray[i] > max1)
{
max2 = max1;
max1 = intArray[i];
}
else
{
if (intArray[i] > max2)
{
max2 = intArray[i];
}
}
}
Console.WriteLine(max2);
}
}
}
using System;
namespace ConsoleApp3
{
internal class Program
{
static void Main(string[] args)
{
string str = "asarsat";
char t=' ';
for(int i=0; i<str.Length; i++)
{
int count = 1;
for (int j = 0; j < str.Length; j++)
{
if (i!=j)
{
if (str[i] == str[j])
{
count++;
break;
}
}
}
if (count == 1)
{
Console.WriteLine(str[i]);
break;
}
}
Console.WriteLine(t);
}
}
}
using System;
namespace ConsoleApp3
{
internal class Program
{
static void Main(string[] args)
{
string str = "aaet";
char t=' ';
for(int i=0; i<str.Length; i++)
{
bool count = true;
for (int j = 0; j < str.Length; j++)
{
if (str[i] == str[j] && i != j)
{
count = false;
break;
}
}
if (count)
{
t= str[i];
break;
}
}
Console.WriteLine(t);
}
}
}
using System;
namespace ConsoleApp3
{
internal class Program
{
static void Main(string[] args)
{
string str = "eaaet";
char t=' ';
for(int i=0; i<str.Length; i++)
{
int count = 1;
for (int j = 0; j < str.Length; j++)
{
if (str[i] == str[j] && i != j)
{
count++;
break;
}
}
if (count==1)
{
t= str[i];
break;
}
}
Console.WriteLine(t);
}
}
}
string str="noion";
int strlen=str.Length;
bool isHwc=true;
for(int i=0; i < strlen/2; i++)
{
if (str[i] != str[strlen-1 - i])
{
isHwc=false;
break;
}
}
Console.WriteLine(isHwc);
int[] arr=[1,2,3,1,5,7,9,4,2,6,9,8];
int max=0;
int count=1;
for(int i = 1; i < arr.Length; i++)
{
if (arr[i] > arr[i-1])
{
count++;
if (count>max)
{
max=count;
}
}
else
{
count=1;
}
}
Console.WriteLine(max);
int[] oldarr={1,2,3,4,6,5,7,8};
int[] oldarr2=oldarr;
int oldarrlen=oldarr.Length;
int count=0;
for(int i = 0; i < oldarrlen; i++)
{
bool swap=false;
for(int j = 0; j < oldarrlen - i-1; j++)
{
if (oldarr[j] > oldarr[j+1])
{
int temp=oldarr[j+1];
oldarr[j+1]=oldarr[j];
oldarr[j]=temp;
swap=true;
}
count++;
}
// 如果内层循环没有交换,数组已排序,提前终止
if (!swap)
{
break;
}
}
Console.Write("排序前:");
foreach(int item in oldarr2)
{
Console.Write(item+ " ");
}
Console.WriteLine();
Console.Write("排序后:");
foreach(int item in oldarr)
{
Console.Write(item+ " ");
}
Console.WriteLine();
Console.WriteLine("循环次数:"+count);