回 帖 发 新 帖 刷新版面

主题:[原创]一组英语UNIX/LINUX题目~~高手做做 英语回答~!

1. UNIX/LINUX commands
1.1 Give the command to list all files in the current directory:
%
Give the command to list all the files whose name starts with a digit in the current directory:
%
Give the command to count all the files whose name starts with a digit in the current directory:
%
1.2 Give the command to find if there is a username “john” in file /etc/passwd:
%
Give the command to print any line containing number 3.14 in datafile:
%
1.3 Give the command to replace all occurrences of “john” with “John” in datafile:
%
1.4 Give the command to find if there is any file named “foo.sp” in the current directory and its
sub-directories:
%





2. Point out any possible errors in the following C code:
int Tcl_SplitList(char *list, int *argcPtr, char ***argvPtr);
/* The given string “list” is parsed into tokens, the number
* of tokens and the token list are returned in argcPtr, argvPtr
*/
void func1(const char *string)
{
int *argc, i, j;
int **data, Nx = 200, Ny = 200;
char ***argv;
Tcl_SplitList(string, argc, argv);
data = (int **)malloc(sizeof(int)*Nx*Ny);
for (i = 0; i < Nx, i++) {
for (j = Ny, j >= 0, j--)
data[i][j] = 0; /* initialization */
}
data[0][0] = atoi(argv[0]);
free(argv);
return;
}






3. Following is a list of code of a C function, assuming element values in array xx[] are monotonic:
unsigned
locate(
double *xx,
double x,
unsigned l,
unsigned u)
{
unsigned ascnd, jl, ju, jm;
jl = l;
ju = u;
ascnd = xx[u] > xx[l];
while (1 < ju - jl ) {
jm = (ju + jl) >> 1;
if (x > xx[jm] == ascnd)
jl = jm;
else
ju = jm;
}
return (jl);
}




Describe what this function does, what the return value “jl” would be? Describe the runtime of
this function with respect to the array size:


4. Write a C or C++ program that reads a string from standard input or a file, then reverse the
string and print the result out to the standard output:

回复列表 (共1个回复)

沙发

1.1
// ls all regular files
ls 
// ls all files
ls -a
//ls all files started with digit
ls | grep '^[0-9]\(\.\)*'

all tested correct!

我来回复

您尚未登录,请登录后再回复。点此登录或注册