The Fourth Dimension Space

枯叶北风寒,忽然年以残,念往昔,语默心酸。二十光阴无一物,韶光贱,寐难安; 不畏形影单,道途阻且慢,哪曲折,如渡飞湍。斩浪劈波酬壮志,同把酒,共言欢! -如梦令

自学笔记整理

//test.cs
using System;
class Student: IComparable
{
string name;
int Grade;
bool Listen;
public Student(string n)
{
name = n;
Grade = 0;
Listen = false;
}
public void print()
{
Console.WriteLine(name);
}
public string getname()
{
return name;
}
#region 
public int CompareTo(Student b)
{
return this.name.CompareTo(b.getname());
}
#endregion
static void Main(string[] args)
{
}
}
//prog.cs
class Program
{
static void Main(string[] args)
{
Student a = new Student ("aa");
Student b = new Student ("bb");
Swap(ref a, ref b);
a.print();
b.print();
}
static void Swap(ref Student a , ref Student b)
{
Student tem = a;
a = b;
b = tem;
Student[] stu = new Student[5];
stu[0] = new Student("bb");
stu[1] = new Student("aa");
stu[2] = new Student("dd");
      stu[3] = new Student("cc");
stu[4] = new Student("ee");
foreach(Student s in stu)
s.print();
var stu2 = stu.Orderby(o=>o.name);
foreach(Student s in stu2)
s.print();
}
}
//public class Cmp : IComparer<Student>
//{
// int IComparer<Student>.Compare(Student a, Student b)
// {
// return a.getname()< b.getname();
// }
//}

#include<iostream>
#include
<cstdio>
#include
<cstdlib>
#include
<sstream>
#include
<string>
#include
<sys/types.h>
#include
<sys/wait.h>
                                                
using namespace std;

const int MAXN = 1000;
char hostname[MAXN];
char pathname[MAXN];
string cmline;
string cm1;
string cm2;
int main()
{
    cout
<<"------------------strat of SHELL program---------------------"<<endl;
    

    
while(true)    
    
{
        istringstream scin(cmline);
        gethostname(hostname,MAXN);
        getcwd(pathname,MAXN);
        printf(
"%s %s $ ",hostname,pathname);
        
int status;
        getline(cin,cmline);
        scin
>>cm1;
        getline(scin,cm2);
        cout
<<cmline<<endl;
        cout
<<cm1<<endl;
        cout
<<cm2<<endl;
        
if(cm1=="cd")
        
{
            system(cmline.c_str());
            cout
<<cmline<<endl;
            
continue;
        }

        
if(fork()!=0)
        
{
            waitpid(
-1,&status,0);    
        }

        
else
        
{

    
//        cout<<cm1<<endl;
    
//        cout<<cm2<<endl;
    
//        system("ls -l");
            system((cmline).c_str());
        }

    }


    cout
<<"-------------------end of SHELL program----------------------"<<endl;
    
return 0;

}


package testcase;

import static org.junit.Assert.*;

import org.junit.Test;

import demo.test;

public class mytest {
    
    @Test
    public void testAdd() {
        
        assertEquals(5.0,test.add(2, 3), 0.0);
    }
    
    @Test
    public void another() {
        
        assertEquals(1.0,test.add(2, 3), 0.0);
    }
}

 package demo;


public class test {
    public static int add(int a,int b)
    {
        
        return a+b;
    }
        
    
}

posted on 2014-09-02 23:27 abilitytao 阅读(205) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理