请问 如下程序中的-n和-x有什么用呢?看不太懂啊,谢谢
来源:百度知道 编辑:UC知道 时间:2024/09/21 22:27:06
#include <stdio.h>
#include <string.h>
#define MAXLINE 1000
int getline(char *line, int max);
/* find: print lines that match pattern from 1st arg */
main(int argc, char *argv[])
{
char line[MAXLINE];
long lineno = 0;
int c, except = 0, number = 0, found = 0;
while (--argc > 0 && (*++argv)[0] == '-')
while (c = *++argv[0])
switch (c) {
case 'x':
except = 1;
break;
case 'n':
number = 1;
break;
default:
printf("find: illegal option %c\n", c);
argc = 0;
found = -1;
break;
}
if (argc != 1)
printf("Usage: find -x -n pattern\n");
else
while (getline(line, MAXLINE) > 0) {
lineno++;
if ((strstr(line, *argv) != NULL) != except) {
if (number)
printf("%ld:", lineno);
printf("%s", line);
fou
#include <string.h>
#define MAXLINE 1000
int getline(char *line, int max);
/* find: print lines that match pattern from 1st arg */
main(int argc, char *argv[])
{
char line[MAXLINE];
long lineno = 0;
int c, except = 0, number = 0, found = 0;
while (--argc > 0 && (*++argv)[0] == '-')
while (c = *++argv[0])
switch (c) {
case 'x':
except = 1;
break;
case 'n':
number = 1;
break;
default:
printf("find: illegal option %c\n", c);
argc = 0;
found = -1;
break;
}
if (argc != 1)
printf("Usage: find -x -n pattern\n");
else
while (getline(line, MAXLINE) > 0) {
lineno++;
if ((strstr(line, *argv) != NULL) != except) {
if (number)
printf("%ld:", lineno);
printf("%s", line);
fou
看while循环
case 'x':
except = 1;
break;
case 'n':
number = 1;
就是这里了,当你运行 find -x 时 except=1,find -n 时,number=1。也就是给find程序定义了两个参数 -x -n。
就像是在dos命令中输入的命令参数一样的.根据这两个参数来确定进行什么操作.
c++ 中x的n次方的流程图。程序如下#include <iostream>
我这边有个求n阶程和的程序运行不成功请大家帮忙:程序如下
请问Vb中“left[$](x,n)”中的[$]是什么意思啊?
如下程序x前为什么要加*
请问 x^n+y^n=? x^n-y^n=? (x+y)^n=? (x+y)^n=? 谢谢
数列的3^n-1按第n组有n个数的规律分组如下:(1) (3,9)`````第100组中的第一个数为多少
有n*n矩阵 按如下格式输出
C#中的For循环,x++和++x有何区别
若(x的平方-x+2)(x的平方+mx+n)中不含x的平方项和x的立方项,求m的平方-n的平方。为什么题目中的x不能取0?
请问这段求N阶乘的程序有什么问题?