Posts Tagged ‘C#’

6
十二月

NHIRD_CD

   Posted by: admin    in 104(上)

class NHIRD_CD
    {
        public string FEE_YM;
        public string APPL_TYPE;
        public string HOSP_ID;
        public string APPL_DATE;
        public string CASE_TYPE;
        public string SEQ_NO;
 
        public string CURE_ITEM_NO1;
        public string CURE_ITEM_NO2;
        public string CURE_ITEM_NO3;
        public string CURE_ITEM_NO4;
 
        public string FUNC_TYPE;
        public string FUNC_DATE;
        public string TREAT_END_DATE;
 
        public string ID_BIRTHDAY;
        public string ID;
 
        public string CARD_SEQ_NO;
        public string GAVE_KIND;
        public string PART_NO;
 
        public string ACODE_ICD9_1;
        public string ACODE_ICD9_2;
        public string ACODE_ICD9_3;
 
        public string ICD_OP_CODE;
        public string DRUG_DAY;
        public string MED_TYPE;
 
        public string PRSN_ID;
        public string PHAR_ID;
 
        public string DRUG_AMT;
        public string TREAT_AMT;
        public string TREAT_CODE;
        public string DIAG_AMT;
        public string DSVC_NO;
        public string DSVC_AMT;
        public string BY_PASS_CODE;
        public string T_AMT;
        public string PART_AMT;
        public string T_APPL_AMT;
        public string ID_SEX;
 
        public NHIRD_CD(string line)
        {
            if (line.Length == 299)
            {
                FEE_YM = line.Substring(0, 6);
                APPL_TYPE = line.Substring(6, 1);
                HOSP_ID = line.Substring(7, 34);
                APPL_DATE = line.Substring(41, 8);
                CASE_TYPE = line.Substring(49, 2);
                SEQ_NO = line.Substring(51, 6);
 
                CURE_ITEM_NO1 = line.Substring(57, 2);
                CURE_ITEM_NO2 = line.Substring(59, 2);
                CURE_ITEM_NO3 = line.Substring(61, 2);
                CURE_ITEM_NO4 = line.Substring(63, 2);
 
                FUNC_TYPE = line.Substring(65, 2);
                FUNC_DATE = line.Substring(67, 8);
                TREAT_END_DATE = line.Substring(75, 8);
                ID_BIRTHDAY = line.Substring(83, 8);
                ID = line.Substring(91, 32);
 
                CARD_SEQ_NO = line.Substring(123, 2);
                GAVE_KIND = line.Substring(126, 1);
                PART_NO = line.Substring(127, 3);
 
                ACODE_ICD9_1 = line.Substring(130, 5).Trim();
                ACODE_ICD9_2 = line.Substring(135, 5).Trim();
                ACODE_ICD9_3 = line.Substring(140, 5).Trim();
 
                ICD_OP_CODE = line.Substring(145, 4);
                DRUG_DAY = line.Substring(149, 2);
 
                MED_TYPE = line.Substring(151, 1);
                PRSN_ID = line.Substring(152, 32);
                PHAR_ID = line.Substring(184, 32);
 
                DRUG_AMT = line.Substring(216, 8);
                TREAT_AMT = line.Substring(224, 8);
                TREAT_CODE = line.Substring(232, 12);
                DIAG_AMT = line.Substring(244, 8);
 
                DSVC_NO = line.Substring(252, 12).Trim();
                DSVC_AMT = line.Substring(264, 8).Trim();
                BY_PASS_CODE = line.Substring(272, 2).Trim();
                T_AMT = line.Substring(274, 8).Trim();
                PART_AMT = line.Substring(282, 8).Trim();
                T_APPL_AMT = line.Substring(290, 8).Trim();
                ID_SEX = line.Substring(298, 1);
            }
            else if (line.Length == 300)
            {
                int x = 1;
                FEE_YM = line.Substring(0, 6);
                APPL_TYPE = line.Substring(6, 1);
                HOSP_ID = line.Substring(7, 34);
                APPL_DATE = line.Substring(41, 8);
                CASE_TYPE = line.Substring(49, 2);
                SEQ_NO = line.Substring(51, 6);
 
                CURE_ITEM_NO1 = line.Substring(57, 2);
                CURE_ITEM_NO2 = line.Substring(59, 2);
                CURE_ITEM_NO3 = line.Substring(61, 2);
                CURE_ITEM_NO4 = line.Substring(63, 2);
 
                FUNC_TYPE = line.Substring(65, 2);
                FUNC_DATE = line.Substring(67, 8);
                TREAT_END_DATE = line.Substring(75, 8);
                ID_BIRTHDAY = line.Substring(83, 8);
                ID = line.Substring(91, 32);
 
                CARD_SEQ_NO = line.Substring(123, 4);//2->4
                GAVE_KIND = line.Substring(126 + x, 1);
                PART_NO = line.Substring(127 + x, 3);
 
                ACODE_ICD9_1 = line.Substring(130 + x, 5).Trim();
                ACODE_ICD9_2 = line.Substring(135 + x, 5).Trim();
                ACODE_ICD9_3 = line.Substring(140 + x, 5).Trim();
 
                ICD_OP_CODE = line.Substring(145 + x, 4);
                DRUG_DAY = line.Substring(149 + x, 2);
 
                MED_TYPE = line.Substring(151 + x, 1);
                PRSN_ID = line.Substring(152 + x, 32);
                PHAR_ID = line.Substring(184 + x, 32);
 
                DRUG_AMT = line.Substring(216 + x, 8);
                TREAT_AMT = line.Substring(224 + x, 8);
                TREAT_CODE = line.Substring(232 + x, 12);
                DIAG_AMT = line.Substring(244 + x, 8);
 
                DSVC_NO = line.Substring(252 + x, 12).Trim();
                DSVC_AMT = line.Substring(264 + x, 8).Trim();
                BY_PASS_CODE = line.Substring(272 + x, 2).Trim();
                T_AMT = line.Substring(274 + x, 8).Trim();
                PART_AMT = line.Substring(282 + x, 8).Trim();
                T_APPL_AMT = line.Substring(290 + x, 8).Trim();
                ID_SEX = line.Substring(298 + x, 1);
            }
        }
    }

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,

7
一月

程式設計一程式 1/7: Ex10.cs

   Posted by: admin    in 103(上)程式設計(一)

using System;
using System.IO;
 
namespace Ex10
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = 1000;
            int i, j, k;
            int max, index;
            int[] a = new int[6];//int a[6];
            int[] ball = new int[49];//int ball[49];
 
            Random rnd = new Random();
            try//FILE* fout;  
            {
                //fopen("lotto.txt" "w");
                StreamWriter sw = new StreamWriter("lotto.txt");
                for (k = 0; k < N; k++)
                {
                    //給每一顆球不同的重量 
                    for (i = 0; i < 49; i++)
                        //ball[i] = rnd.nextInt();//rand();
                        ball[i] = rnd.Next();
                    //取出最重的球(6次) 
                    for (i = 0; i < 6; i++)
                    {
                        max = 0; index = 0;
                        for (j = 0; j < 49; j++)
                        {
                            if (ball[j] > max)
                            {
                                max = ball[j];
                                index = j;
                            }
                        }
                        a[i] = index + 1;//最重的球編號 
                        ball[index] = 0; //把最重的球重量歸零 
                    }
                    //System.out.printf("The number is %2d %2d %2d %2d %2d %2d\n", 
                    Console.WriteLine("{0,2} {1,2} {2,2} {3,2} {4,2} {5,2}", a[0], a[1], a[2], a[3], a[4], a[5]);
                    sw.WriteLine("{0,2} {1,2} {2,2} {3,2} {4,2} {5,2}", a[0], a[1], a[2], a[3], a[4], a[5]);
                }
                sw.Close();
            }
            catch (FileNotFoundException fe)
	        {
                //System.out.printf(fe.getMessage());
	    	    Console.WriteLine(fe.Message);
	        }
	        catch (IOException e)
	        {
	    	    //System.out.printf(fe.Message);
                Console.WriteLine(e.Message);
	        }
        }
    }
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,

24
十二月

C程式設計:C#版本的大樂透彩單程式

   Posted by: admin    in 98(上)C程式設計

using System;
 
namespace LottoTicket2
{
    class Program
    {
        static Random random = new Random();
        static void Main(string[] args)
        {
            int i,j, nStakeNum=1;
	        int[] NumList =  new int[6];
	        if (args.Length >=1)
	        {
		        nStakeNum=int.Parse(args[0]);
		        if (nStakeNum<=0||nStakeNum>5)
		        {
                    System.Console.WriteLine("1~5 stakes one time");
			        return;
		        }
	        }
 
	        for (i=0; i<nStakeNum; i++)
	        {
		        LottoNumGen(NumList);
		        for (j=0; j< 6; j++)
                    System.Console.Write("{0:00} ", NumList[j]);
                System.Console.WriteLine();
	        }
        }
        static void LottoNumGen(int[] List)
        {
            int i, j;
            int[] number=new int[49];
            int highest, which;
 
            for (i=0; i<49; i++)
            {
                number[i] = random.Next();
            }
            for (i=0; i<6; i++)
            {
               highest = 0; which = -1;
               /*每次選最高分*/
               for (j=0; j< 49; j++)
               {
                   if (number[j] > highest)
                   {
                       highest = number[j]; which=j;
                   }
               }
               List[i]=which+1; number[which]=0;
            }
        }
    }
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

17
十二月

C程式設計:將C程式改寫成C#程式

   Posted by: admin    in 98(上)C程式設計

20091217CS

使用Visual Studio Express寫C#程式

使用Visual Studio Express寫C#程式

 

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

using System;
namespace LottoTicket1
{
    class Program
    {
        static void Main(string[] args)
        {
           /*在以下寫程式*/
 
	       /*寫到這裡*/
        }
        void LottoNumGen(int[] List)
        {
	    /*在以下寫程式*/
 
	    /*寫到這裡*/
        }
    }
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,