zoukankan      html  css  js  c++  java
  • 我的第一次笔试

    今天是我的第一次应骋,招聘的单位是联信永益,这个公司是来我们学校招聘,事先我们老师跟我们说了一下,由于我们正在做我们老师给我们介绍的一小型的商业茶叶网站项目,也就没把它当回事,自我感觉良好,今天要应骋了,昨晚还在做那个网站,而且弄到了2点半才睡觉,7点起来时感觉很糊涂,起来洗个澡,总算是清醒了很多,冲冲忙忙的制作了一份非常简陋的简历,就这样的去了。

    首先公司作了一下他们介绍,然后笔试了,笔试过了,再是面试。第一个题目我一看就想到了它的解法,后来糊里糊涂写成另一种意思了。其实这次的笔试主要是这一题和下一题,这题本来信心是很足的,第二题没信心的,有信心都做错了,没信心的就更不用说。

    总的来说应骋前没准备好、没休息好、基础知识不牢靠。

    下面这是笔试题目:

    第一题:写一个方法,它的功能性是输入一串字符去掉这一串中重复的字符。

    我原来的解法就不说了,我现在的解法是:

    View Code
     1 using System;  
    2 02.using System.Collections.Generic;
    3 03.using System.Linq;
    4 04.using System.Text;
    5 05.
    6 06.namespace ConsoleApplication20
    7 07.{
    8 08. class Program
    9 09. {
    10 10. static void Main(string[] args)
    11 11. {
    12 12. String str1=String.Empty;
    13 13. Console.Write("请输入一串字符:");
    14 14. str1 = Console.ReadLine();
    15 15. str1 = Alike(str1);
    16 16. Console.WriteLine("去掉从复后的字符串:{0}",str1);
    17 17. Console.ReadLine();
    18 18. }
    19 19. static String Alike(String str1)
    20 20. {
    21 21. String str="";
    22 22. for (int i = 0; i < str1.Length; i++)
    23 23. {
    24 24. //如果str1[i]不在str1的0到i的位置中,则返回-1,那么就把他加到str字符串里。
    if (str1.IndexOf(str1[i], 0, i) == -1)
    25 25. str += str1[i];
    26 26. }
    27 27. return str;
    28 28. }
    29 29. }
    30 30.}

    以下是我在CSDN论坛上发表后,网友的一些解法:

    网友:huangwenquan123

    View Code
     1         static string Alike(string str)
    2 {
    3 bool[] arr = new bool[52];
    4 string result = string.Empty;
    5 int temp;
    6 foreach (char c in str)
    7 {
    8 temp = c - 'A' >= 32 ? c - 'a' + 26 : c - 'A';
    9 if (!arr[temp])
    10 {
    11 result += c.ToString();
    12 arr[temp] = true;
    13 }
    14 }
    15 return result;
    16 }

    网友:hengxinyi

    View Code
     1 static void Main(string[] args)
    2 {
    3 List<char> list = new List<char>();
    4 string str = Console.ReadLine();
    5 for (int i = 0; i < str.Length; i++)
    6 {
    7 if (!list.Contains(str[i]))
    8 {
    9 list.Add(str[i]);
    10 }
    11 }
    12 foreach (char n in list)
    13 {
    14 Console.WriteLine(n);
    15 }
    16 Console.ReadLine();
    17 }

    大家还有更快更好的算法吗?希望大家能和我分享一下。
    第二题:有三对老虎分别用Aa Bb Cc表示,每一对老虎由一只母老虎和子老虎组成,三对老虎从这边河坐船到那边河,这个船每次只能坐2只老虎,任意一只没有和母老虎在一起,就会被其他母老虎吃掉。

    这道题我没公布解法,本来打算有10个网友回复再公布,被网友xhloo第一个回帖就公布了解法:

    View Code
    1 1、Aa-〉右 BbCc Aa
    2 2、A->左 BbCcA a
    3 3、bc-〉右 ABC abc
    4 4、c-〉左 ABCc ab
    5
    6 5、AB ->右 Cc AaBb
    7 6、Bb-〉左 BbCc Aa
    8 7、BC-〉右 bc AaBC
    9 8、a-〉左 abc ABC

    谁能帮我用C#代码写出来呢?这我现在还真有点写不出。

    欢迎访问草根帮【https://www.caogenbang.top】 草根帮带你走向人生巅峰,迎娶白富美!!!
  • 相关阅读:
    WebGL-四之二
    WebGL-四之一
    mybatis中批量更新的问题
    nginx+tpmcat+redis实现session共享
    myeclipse快捷方式汇总
    StringBuffer的append方法比“+”高效
    《Thinking in Java》 And 《Effective Java》啃起来
    JAVA链表中迭代器的实现
    myeclipse从SVN检出项目报错
    C#中清空ListView中的数据
  • 原文地址:https://www.cnblogs.com/koeltp/p/2307939.html
Copyright © 2011-2022 走看看