这是一个C#新人的学习笔记---7

76 阅读1分钟

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp4
{
internal class Program
{
static void Main(string[] args)
{
//判断一个字符是不是回文串  level noon 奇数 偶数
/*string str=Console.ReadLine();
bool res = true;
for (int i = 0; i < args.Length / 2; i++)
{
if (str[i] != str[str.Length - 1 -i]) res = false;

           }
Console.WriteLine(res?"是回文串str":"是回文串{str}":"不是回文串{str}");//$表示字符串的格式化输出,大括号中表示变量名   
*/

            //需要有一个变量来记录最长连续下降的天数,另外一个变量来记录每一次连续下降温度的天数
//输入内容
/string[] tempStr = Console.ReadLine().Split(' ');
int[] intArray = new int[tempStr.Length];
for (int i = 0; i < tempStr.Length; i++)
{
intArray[i] = Convert.ToInt32(tempStr[i]);
}
int maxDay = 1;
int count = 1;
for (int i = 0; i < intArray.Length; i++)
{
//如果当前的数比前面的数大,那么下降就中断了,一旦中断我们就要记录当天连续天数和最大的连续天数进行对比
if (intArray[i] >= intArray[i - 1])//34 23 43 23 10什么情况我去记录的最大值 后面有一个比他大的才会记录最大值
{     
if (count > maxDay)
{
maxDay = count;

}
count = 1;
continue;
}
count++;
}
//maxDay=count>maxDay?count:maxDay;
//Console.WriteLine(maxDay);
/

            /string[] strArrary=Console.ReadLine().Split(' ');
int[] budgets=new int[strArrary.Length];
for (int i=0;i<strArrary.Length;i++)
{
budgets[i] = Convert.ToInt32(strArrary[i]);
}
//变量记录小明每个月剩下的钱,还有妈妈那里的有多少钱
int mymoney = 0;
int mom = 0;
bool flag = true;
for (int i = 0; i < strArrary.Length; i++)
{
//计算一下每次小明剩下了多少钱
mymoney = mymoney + 300 - budgets[i];
if (mymoney < 0)
{
Console.WriteLine(-(i + 1));
flag = false;
break;
}
//如果小明剩下的钱大于等于0 这时候要考虑给妈妈钱
mom = mymoney / 100;
mymoney = (mymoney / 100) * 100;//最终剩下的钱
}
if(flag)
{
Console.WriteLine(Convert.ToInt32(mom * 1.2));
}
/

            string str = "basketball";
int[] intArray = new int[7];
foreach(char i in str)
{
if(i=='a')
{
intArray[0]++;
}
else if(i=='b')
{

                }
}
intArray[6] /= 2;

        }
}
}