我试图找到awk一个类的第二列数据的平均值.这是我当前的代码,我的讲师提供了框架:
#!/bin/awk
### This script currently prints the total number of rows processed.
### You must edit this script to print the average of the 2nd column
### instead of the number of rows.
# This block of code is executed for each line in the file
{
x=sum
read name
awk 'BEGIN{sum+=$2}'
# The script should NOT print out a value for each line
}
# The END block is processed after the last line is read …Run Code Online (Sandbox Code Playgroud) 我正在尝试用 C 语言为一个类构建一个非常简单的解析器。它所要做的就是从输入文件中读取标志,确定该标志是否位于 int、char 或 float 之前,然后将 int/float/char 写入相应的 .txt 文件。例如 I 9898 将被打印到 int.txt。每当使用讲师提供的测试脚本时,我都会收到以下错误:
\n\nparser.c:1:1: error: unknown type name \xe2\x80\x98e\xe2\x80\x99\nparser.c:1:10: error: expected \xe2\x80\x98=\xe2\x80\x99, \xe2\x80\x98,\xe2\x80\x99, \xe2\x80\x98;\xe2\x80\x99, \xe2\x80\x98asm\xe2\x80\x99 or \xe2\x80\x98__attribute__\xe2\x80\x99 before \xe2\x80\x98on\xe2\x80\x99\nparser.c:1:10: error: unknown type name \xe2\x80\x98on\xe2\x80\x99
这是我的代码,请告诉我。非常感谢:
\n\nint main(int argc, char *argv[])\n{\n#include <stdio.h>\n FILE *input = fopen("input.txt", "r");\n FILE *ints.txt = fopen("ints.txt" "w");\n FILE *chars.txt = fopen("chars.txt", "w");\n FILE *floats.txt = fopen("floats.txt", "w");\n\n char flag;\n int ipint;\n char ipchar;\n float ipfloat;\n int exitStatus = fscanf(input.txt, "%c", &flag);\n\n …Run Code Online (Sandbox Code Playgroud)