求格式化字符算法一个
//想格式化数据为数据加字符的方式,如1 -> 1 ,10->A,同时去除I,O等易混字符,现在的算法在上1000的时候,格式话数据就存在问题,eg:999格式化为ZZ了,1000应该是A00
string strWaterNo = StartValue;
string strWaterNoChr = string.Empty;
int WaterNoCnt = 0;
while (WaterNoCnt < Length - TempDocNo.Length)
{
int WaterNoDigit = int.Parse(((int.Parse(strWaterNo) / int.Parse(Math.Pow(32, WaterNoCnt).ToString())) % 32).ToString());//計算公式111/0%32,111/32%32
if (WaterNoDigit < 10)
{
// WaterNoChr = "0" + WaterNoDigit.ToString()+ WaterNoDigit.ToString();
string strTemp = "0" + WaterNoDigit.ToString();
strWaterNoChr = Convert.ToString(strTemp).Substring(strTemp.Length - 1, 1) + strWaterNoChr;
}
else
{
int intTempWaterNoDigit = WaterNoDigit + 55;
int intTempWaterCharShift = 0;
if (intTempWaterNoDigit >= 72)//减少判断次数,字母I之前不用判断
{
if (intTempWaterNoDigit + intTempWaterCharShift >= (int)'I')
intTempWaterCharShift = intTempWaterCharShift + 1;
if (intTempWaterNoDigit + intTempWaterCharShift >= (int)'O')
intTempWaterCharShift = intTempWaterCharShift + 1;
if (intTempWaterNoDigit + intTempWaterCharShift >= (int)'U')
intTempWaterCharShift = intTempWaterCharShift + 1;
if (intTempWaterNoDigit + intTempWaterCharShift >= (int)'V')
intTempWaterCharShift = intTempWaterCharShift + 1;
}
strWaterNoChr = Convert.ToString((char)(intTempWaterNoDigit + intTempWaterCharShift)) + strWaterNoChr;
}
WaterNoCnt++;
}
string strWaterNo = StartValue;
string strWaterNoChr = string.Empty;
int WaterNoCnt = 0;
while (WaterNoCnt < Length - TempDocNo.Length)
{
int WaterNoDigit = int.Parse(((int.Parse(strWaterNo) / int.Parse(Math.Pow(32, WaterNoCnt).ToString())) % 32).ToString());//計算公式111/0%32,111/32%32
if (WaterNoDigit < 10)
{
// WaterNoChr = "0" + WaterNoDigit.ToString()+ WaterNoDigit.ToString();
string strTemp = "0" + WaterNoDigit.ToString();
strWaterNoChr = Convert.ToString(strTemp).Substring(strTemp.Length - 1, 1) + strWaterNoChr;
}
else
{
int intTempWaterNoDigit = WaterNoDigit + 55;
int intTempWaterCharShift = 0;
if (intTempWaterNoDigit >= 72)//减少判断次数,字母I之前不用判断
{
if (intTempWaterNoDigit + intTempWaterCharShift >= (int)'I')
intTempWaterCharShift = intTempWaterCharShift + 1;
if (intTempWaterNoDigit + intTempWaterCharShift >= (int)'O')
intTempWaterCharShift = intTempWaterCharShift + 1;
if (intTempWaterNoDigit + intTempWaterCharShift >= (int)'U')
intTempWaterCharShift = intTempWaterCharShift + 1;
if (intTempWaterNoDigit + intTempWaterCharShift >= (int)'V')
intTempWaterCharShift = intTempWaterCharShift + 1;
}
strWaterNoChr = Convert.ToString((char)(intTempWaterNoDigit + intTempWaterCharShift)) + strWaterNoChr;
}
WaterNoCnt++;
}
...全文
相关推荐
求字符串长度的函数.rar
求字符串长度的函数
Golang 中整数转字符串的方法
主要介绍了Golang 中整数转字符串的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
求五个数中的最大值和最小值
main() { int a,b,num1,num2,temp; printf("please input two numbers:\n"); scanf("%d,%d",&num1,&num2); if(num1 { temp=num1; num1=num2; num2=temp; } a=num1;b=num2; while(b!=0)/*利用辗除法,直到b为0为止*/ { temp=a%b; a=b; b=temp; } printf("gongyueshu:%d\n",a); printf("gongbeishu:%d\n",num1*num2/a); }
C语言算法ccc
C语言的应用语言的应用和算法
C语言常见编程算法实例
C常见编程算法实例 C常见编程算法实例 C常见编程算法实例


