微软面试题

1 js 实现类A,B A继承于B,并且A重写B的某一个方法
2 java
实现二分法返回一个升序数组的索引
3
现有一元,五角,二角,一角,五分,二分,一分 几种货币,java编写一个方法实现一元钱有多少种组合.
4
接收两个file 参数 inputfile,outputfile,inputfile的内容读出,并转换内容写到outputfile

inputfile
内容
张三 1 300
张三 2
400
李四 1
500
王五 2
600
王五 3
300
outputfile
内容


1
2 3
张三
300 400 500
李四
500 0 0
王五 0 600 300

 

 

答案:

1.       做个简单的Demo
function A(first, last) {
if ( arguments.length > 0 )
this.init(first, last);
}

A.prototype.init = function(first, last) {
this.first = first;
this.last = last;
}


function B(first, last, id) {
if ( arguments.length > 0 )
this.init(first, last, id);
}

B.prototype = new A();
B.prototype.constructor = B;
B.superclass = A.prototype;

B.prototype.init = function(first, last, id) {
// Call superclass method
B.superclass.init.call(this, first, last);

// init properties
this.id = id;
}

 

 

第三题,直接代码给你,如下 :
package com.ce.exam;

public class Calculate {

/**
* 1 5 2 0.1 0.05 0.02 0.01
* @param args
*/
public static void main(String[] args) {
System.out.println("
有如下几种组合
......");
int count = 0; //
记数

for(int x=0;x<=1;x++){
for(int y = 0;y<=2;y++){
for(int a = 0 ; a <=5;a++){
for(int b =0 ; b <= 10 ; b++){
for(int c = 0 ; c <= 20 ; c++){
for(int d = 0 ; d <=50;d++){
for(int e = 0 ; e <= 100; e++){
if(x + 0.5*y + 0.2*a + 0.1*b + 0.05*c + 0.02*d + 0.01*e == 1){
count ++ ;
System.out.println("1
元的" + x + " 5毛的" + y + " 2毛的" + a + " 1毛的" + b
+"
5分的" + c + " 2分的" + d + " 1分的" + e + "
");
}
}
}
}
}
}
}
}
System.out.println("
总共有" + count +"种组合方法
");
}

}

 

 

4..
package com.ce.exam;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class ReadAndWrite {

/**
* @param args
*/
public static void main(String[] args) {
ReadAndWrite rw =new ReadAndWrite();
try {
rw.read("
文件路径
");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

public void read(String filePath) throws IOException{
File file = new File(filePath);
String[][] arr = new String[4][4];
arr[0][0] = "";
arr[0][1] = "1
";
arr[0][2] = "2
";
arr[0][3] = "3
";
arr[1][0] = "
张三
";
arr[2][0] = "
李四
";
arr[3][0] = "
王五
";
BufferedReader br = new BufferedReader(new FileReader(file));
while(br != null){
String temp = br.readLine();
String[] record = temp.split(" ");
String name = record[0];
String month = record[1];
String money = record[2];

//
将有数据的月份存放好

for(int i = 1 ; i <=3 ; i++){
if(month.equals(arr[0][i])){
for(int j=1;j<=3;j++){
if(name.equals(arr[j][0])){
arr[j][i] = money;
}
}
}
}
}
//
处理那些没有的值的月份
for(int i = 1 ; i <= 3;i++){
for(int j=1;j<=3;j++){
if(arr[i][j]==null || arr[i][j]==""){
arr[i][j] = "0";
}
}
}
//
arr写出到一个文件中...代码略
//
如果这部分你自己搞不定,那就回家吃饭去吧........


}

}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值