d****n 发帖数: 1637 | 1 my shabby code for questions 4.
//File resovle.c
#include
#include
#include
#define MAXLINECHARSIZE 1000
inline int fsplit(char *line, char **items, char delim);
int main(int argc, char * argv[]){
/***prepare && allocate buffer/space***/
int n,nbytes=100, maxcol=10, maxchar=1000;
char **items;
{
items=(char **) malloc(maxcol*sizeof(char *));
int i;
for(i=0; i
items[i]=(char*)malloc(maxchar*sizeo... 阅读全帖 |
|
i**********e 发帖数: 1145 | 2 My code for 9).
string extractUntilDelim(string s, int i, char delim) {
int n = s.length();
string ans;
for (int j = i; j < n; j++) {
if (s[j] == delim)
return ans;
else
ans += s[j];
}
return ans;
}
// constraint: path must begin with a '/'.
// "/var/www/html/../.././lc" -> "/var/lc/"
// "/../../ -> "/"
string simplifyUnixFilePath(string path) {
deque directories;
int n = path.length();
for (int i = 0; i < n; i++) {
char c = path[i];
if (c == '... 阅读全帖 |
|
i**********e 发帖数: 1145 | 3 My code for 9).
string extractUntilDelim(string s, int i, char delim) {
int n = s.length();
string ans;
for (int j = i; j < n; j++) {
if (s[j] == delim)
return ans;
else
ans += s[j];
}
return ans;
}
// constraint: path must begin with a '/'.
// "/var/www/html/../.././lc" -> "/var/lc/"
// "/../../ -> "/"
string simplifyUnixFilePath(string path) {
deque directories;
int n = path.length();
for (int i = 0; i < n; i++) {
char c = path[i];
if (c == '... 阅读全帖 |
|
S**I 发帖数: 15689 | 4 ☆─────────────────────────────────────☆
recursive (递归) 于 (Mon Apr 11 10:56:49 2011, 美东) 提到:
大半夜收到HR的thank you note。不用管什么NDA了
本人ECE fresh PhD,背景是电路/EDA,跟G业务基本没什么关系
同学内部推荐的,很简单的一次电面就给了onsite
题都不难,但是自己没把握好机会,出了一些小bug。
总的感觉,出错就是硬伤,宁可从最简单的算法写起,也不能出错。
电面:
1,Skip list, http://en.wikipedia.org/wiki/Skip_list
写code实现struct skip_list * find(struct skip_list *head, int value)
2,sorted array with repeated elements
for given element, find out its range.
e.g. A A B B B B B C C D D E F G, given B, the out... 阅读全帖 |
|
f*******r 发帖数: 976 | 5 题目就是external sort的思想。统计单词的次数,明显用map。注意文
件很大,要用long,以免溢出。
在你读文件并且增加这个map时,内存不够用,这是你要把临时结果写入临时文件。你
可以设计一个threshold,比如1 billion,当map的size达到这个值时,你就把map和临
时文件merge到另一个临时文件里。最后再把这个文件rename到原来的临时文件。再把
map清空,继续读原文件直到结束。 C++代码如下:
// Split the string into words that consists of a..z and A..Z.
void split(const string &s, vector &res) {
int beg = -1;
for (int i = 0, e = s.size(); i < e; ++i) {
if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z')) {
if (beg == ... 阅读全帖 |
|
t****t 发帖数: 6806 | 6 [27.6.1.3]
....
basic_istream& get(basic_streambuf& sb,
char_type delim );
Effects:
Extracts characters and inserts them in the output sequence con-
trolled by sb. Characters are extracted and inserted until any of
the following occurs:
--end-of-file occurs on the input sequence;
--inserting in the output sequence fails (in which case the character
to be inserted is not extracted);
--c == delim for the next ava |
|
R****n 发帖数: 708 | 7 my simple R code. Try to read the basic R, and you should be able to get it
in a few weeks.
setwd("C:/Users/meng09/Downloads/BRCA/BCGSC__IlluminaHiSeq_miRNASeq/Level_3")
lst<-list.files()
exprtable<-c()
Nam<-c()
for (f in lst) {
temp<-read.delim(f)
Nam<-c(Nam,as.character(temp[1,"barcode"]))
exprtable<-cbind(exprtable,temp[,"reads_per_million_miRNA_mapped"])
}
exprtable[1:5,1:5]
exprs<-as.data.frame(exprtable)
samp<-Nam
probe<-as.character(temp[,"miRNA_ID"])
names(exprs)<-samp
rownames(exp... 阅读全帖 |
|
w*****1 发帖数: 473 | 8 一个是space delim, 另外一个不知道是什么delim的,没办法用excel 打开。当初用
cut的时候用了space. |
|
d*****1 发帖数: 123 | 9 那个所谓的木马是批处理文件,人家的源码都给了,用EXEScript打包的。垃圾杀软就
这样。
sigh
附上源代码:
@Echo Off
COLOR 2F
Set Prog=老毛桃制作的 WinPE 专用安装工具
Set L1= ╭══════════════════╮
Set L2= ║ ║
Set L3= ╭══┤ %Prog% ├══╮
Set L4= ║ ║ ║ ║
Set L5= ║ ╰══════════════════╯ ║
Set L6= ║ ║
Set L7= ╟════════════════════════╢
Set L8= ║ 版权所有:老毛桃 仅供网友们交流 翻版不究 ║
Set L9= ╰————————————————————————╯
Title %Prog%
Set PEFile=WinPE.IS_
Set PEIni=外置程序\WinPE.INI
Set LogFile=PEIn... 阅读全帖 |
|
x*******a 发帖数: 11067 | 10 DC版的高人多多,俺问个技术问题。包子感谢!
【 以下文字转载自 Programming 讨论区 】
发信人: xinyuemba (小树), 信区: Programming
标 题: 一个batch file的问题
发信站: BBS 未名空间站 (Wed Aug 15 15:59:02 2012, 美东)
菜鸟诚惶诚恐地上来请教,花了一天琢磨一个BATCH FILE,就是为了LOOP THROUGH一堆
SUBDIRECTORY,打开每个SUBDIR下面的同一个TEXT文件,然后替换里头的一个参数。
总算是WORK了,但是很多是照葫芦画瓢。特别不明白的是两个
!!中间加一个VARIABLE的名字是啥意思。
特别不明白的是,为啥我不能直接让
%%a=123
echo %%a >>file
必须要让
fa=%%a
set fa=123
echo !fa! >>file
请高手解释一下,谢谢!
程序在下面写的很傻,轻拍。
@echo off
setlocal enabledelayedexpansion
FOR /D %%1 IN ("*") DO (
rem cd to all sub... 阅读全帖 |
|
c*****s 发帖数: 180 | 11 Example
Suppose you want to store the Words macro in compiled form in a SAS library.
This example shows the macro definition for Words. The macro takes a text
string, divides it into words, and creates a series of macro variables to
store each word.
Notice that the STORE option is used in the macro definition so that Words
will be permanently stored as a compiled macro, as follows:
libname macrolib 'c:\storedlib';
options mstored sasmstore=macrolib;
%macro words(text,root=w,delim= |
|
i*******d 发帖数: 81 | 12 请问DB2中可以用table variable么?
SQL Server中很容易实现:
CREATE FUNCTION dbo.f_Name(
@List VARCHAR(2000)
,@Delim VARCHAR(10)
)
RETURNS VARCHAR(2000)
AS
BEGIN
DECLARE @t_Name TABLE (Item VARCHAR(2000))
.....................
.....................
RETURN @sth
END
GO
DB2有类似的功能么?多谢! |
|
a****x 发帖数: 231 | 13 取消所有路由走vpn?然后搞个批处理文件改路由?
我用这个批处理加192.168.0.0,10.0.0.0 到路由表,你可以参考一下。
==================================================================
@rem - ASB (10 Oct 2005): Get IP Address and Break Into Individual Octets
@ECHO OFF
SETLOCAL
for /f "tokens=3-7 delims=:. " %%v in ('ipconfig ^| find /i "address"') do
call :GetIPs %%v %%w %%x %%y
ENDLOCAL
GOTO :EOBAT
rem SUBROUTINE
rem %1-%4 = 4 Octets of IP address
if not "%1"=="192" GOTO :EOBAT
if not "%2"=="168" GOTO :EOBAT
ECHO %1.%2.%3.%4
route add 192.168.... 阅读全帖 |
|
h***r 发帖数: 726 | 14 cool, will try!
how to define different delim? say, space and tab? Thanks!
Will send you baozi if it works : ) |
|
m*****n 发帖数: 266 | 15 space delim:
awk -F " " '{print $1 $3 $2 $4}' |
|
p***o 发帖数: 1252 | 16 FOR /F "usebackq delims=" %i IN (`dir c:\*.txt /b`) DO @echo "%i" |
|
r****t 发帖数: 10904 | 17 (2nd function version:)
istream& getline ( istream& is, string& str );
Get line from stream
...
The delimiter character is delim for the first function version, and '\n' (
newline character) for the second. The extraction also stops if the end of
file is reached in is or if some other error occurs during the input
operation.
所以 getline 就从 hello 后面那个空格开始读到 \n 了。 |
|
x*******a 发帖数: 11067 | 18 菜鸟诚惶诚恐地上来请教,花了一天琢磨一个BATCH FILE,就是为了LOOP THROUGH一堆
SUBDIRECTORY,打开每个SUBDIR下面的同一个TEXT文件,然后替换里头的一个参数。
总算是WORK了,但是很多是照葫芦画瓢。特别不明白的是两个
!!中间加一个VARIABLE的名字是啥意思。
特别不明白的是,为啥我不能直接让
%%a=123
echo %%a >>file
必须要让
fa=%%a
set fa=123
echo !fa! >>file
请高手解释一下,谢谢!
程序在下面写的很傻,轻拍。
@echo off
setlocal enabledelayedexpansion
FOR /D %%1 IN ("*") DO (
rem cd to all sub directories
echo %%1
cd %%1
rename OUT.txt OUT.txt1
FOR /F "tokens=1,2,3,4,5,6,7 delims=" %%a IN (OUT.txt1) DO (
set fa=%%a
set fb=%%b
... 阅读全帖 |
|
a***r 发帖数: 420 | 19 我有一个n*m的dataset,里面的信息是两个没有顺序的字母,ie.A B,B C,C B...
因为dataset很大,打算用C++处理,有个基础问题,网上教程老看不明白,
就是如何建立一个string的array?
比如在把这些信息存入C++的array时,我现在是建了一个三维的char数组,可否/如何
直接建立一个
string的二维数组呢?
如果上面这个问题成立,即如果可以有string的数组
有什么好办法可以把一个string分成指定大小,存入指定长度的string的数组呢?
比如我为了sql方便,把每行的m个col合成一个field
相当于成了一维的string数组
然后我在mysql里面sort啥的完了
用getline(cin,line),重新读入c++的二维数组,这时我希望把这个field按两个两
个放到
string的array里,但是getline似乎没有相应的命令,或者,我应该在合成field的时
候,就在每
两个字母间加个delimiter,然后用getline(cin,line,delim)?
另外,从generally的来说,string,是不是可以完全... 阅读全帖 |
|
s**********y 发帖数: 38 | 20 Classification Tree example
Let's use the dataframe kyphosis to predict a type of deformation (kyphosis)
after surgery, from age in months (Age), number of vertebrae involved (
Number), and the highest vertebrae operated on (Start). # Classification
Tree with rpart
library(rpart)
# grow tree
fit <- rpart(Kyphosis ~ Age + Number + Start,
method="class", data=kyphosis)
上面是我从http://www.statmethods.net/advstats/cart.html摘录的code.How to get dataframe from R? 下面是我的程序,但没有任何结果出来, R 也没有ERROR
A=read.del... 阅读全帖 |
|
l*******h 发帖数: 151 | 21 read.csv() is used to read CSV which is delimited by commas. read.table is
usually used to read raw data delimited by space. For your case, reading tab
delimited files, you can also try read.delim(..., sep="\t"). |
|
e*****t 发帖数: 642 | 22 use read.delim
it would be fine |
|
t*****w 发帖数: 254 | 23 When I had my job interview, they always tested my SAS skill.However I use R
all the time. To help your preparation, read my R codes to see how much you
can understand it.
%in%
?keyword
a<-matrix(0,nrow=3,ncol=3,byrow=T)
a1 <- a1/(t(a1)%*%spooled%*%a1)^.5 #standadization in discrim
a1<- a>=2; a[a1]
abline(h = -1:5, v = -2:3, col = "lightgray", lty=3)
abline(h=0, v=0, col = "gray60")
abs(r2[i])>r0
aggregate(iris[,1:4], list(iris$Species), mean)
AND: &; OR: |; NOT: !
anova(lm(data1[,3]~data1[,1... 阅读全帖 |
|
i*e 发帖数: 352 | 24 嗯,那么你也不会想用SNPTEST了
你那个命令貌似没问题,事先有sort过对吧,而且你两个文件应该都是tab-delim的? |
|