zoukankan      html  css  js  c++  java
  • (C#)ACM考试题的第一题

    哈哈!竟用C#写了。偷懒呀!以后还要用C语言再写一次。用C#写这个太简单了。

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;

    namespace ACM1
    {
        
    class Program
        
    {
            
    static void Main(string[] args)
            
    {
                
    if(args.Length==0)
                
    {
                    Console.WriteLine(
    "需要一个文本文件作为参数。格式,第一行为测试案例数,往后每行为测试案例。如|||,||");
                    
    return;
                }

                FileStream fs 
    = new FileStream(args[0],FileMode.Open,FileAccess.Read);
                StreamReader sr 
    = new StreamReader(fs);
                String s
    =sr.ReadLine();
                
    int N = int.Parse(s);
                
    for (int i = 0; i < N; i++)
                
    {
                    s 
    = sr.ReadLine();
                    Console.WriteLine(s
    +":"+ConvertNum(s));
                }


            }

            
    static string ConvertNum(string str)
            
    {
                
    string[] s = str.Split(new char[] ','});
                
    string num = "";
                
    for (int i = 0; i < s.Length; i++)
                
    {
                    num
    +=s[i].Length;
                }

                
    char[] cs = num.ToCharArray();
                
    int nums = 0;
                
    for (int i = 1; i <= cs.Length; i++)
                
    {
                    nums 
    += int.Parse(cs[i - 1].ToString())*(int)Math.Pow(8,cs.Length-i);
                }

                
    return nums.ToString();
            }

        }

    }
  • 相关阅读:
    LINQ to SQL活学活用(2):躲起来别让我看见
    UTF8的問題
    简单的appendChild示例
    LINQ to SQL活学活用(4):监视你的一举一动
    LinQ中的SortBy+sum+count的用法
    ajax的问题
    [综] Canny Edge Detection 代码
    [转] 图像处理中的拉普拉斯算子
    [ZZ] SCI 投稿全过程信件模板一览
    [转] MATLAB图像实用源代码
  • 原文地址:https://www.cnblogs.com/zxsoft/p/938080.html
Copyright © 2011-2022 走看看