use*_*059 -1 c compiler-construction
所以我的教授给了我们一些代码,他说它应该能够编译,但我得到各种错误,不知道什么是错的,因为我对c没有任何经验.它是一个汇编语言类,我们应该编写汇编代码来匹配c代码正在做的事情.他告诉我们在c中运行程序以了解事物.
#include <stdio.h>
#define SIZE 40
main()
{
int v[SIZE];
register int gap, i, j, temp;
/* Initialize array to random positive integers mod 256 */
for (i = 0; i < SIZE; i++)
v[i] = rand() & 0xFF;
/* Display the unsorted array */
for (i = 0; i < SIZE; i++)
printf(“v[%-d] = %-d\n”, i, v[i]);
/* Sort the array using a shell sort */
for (gap = SIZE / 2; gap > 0; gap /= 2) {
for (i = gap; i < SIZE; i++) {
for (j = i - gap; j >= 0 && v[j] > v[j + gap]; j -= gap) {
/* Exchange out of order items */
temp = v[j];
v[j] = v[j + gap];
v[j + gap] = temp;
}
}
}
/* Display the sorted array */
for (i = 0; i < SIZE; i++)
printf(“v[%-d] = %-d\n”, i, v[i]);
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是第15行和第31行的错误,所以每一行都有一个printf.
As3.c: In function ’main’:
As3.c:15: error: stray ’\223’ in program
As3.c:15: error: expected expression before ’%’ token
As3.c:15: error: expected expression before ’%’ token
As3.c:15: error: stray ’\’ in program
As3.c:15: error: stray ’\224’ in program
As3.c:31:error: stray ’\223’ in program
As3.c:31:error: expected expression before ’%’ token
As3.c:31:error: expected expression before ’%’ token
As3.c:31:error: stray ’\’ in program
As3.c:31:error: stray ’\224’ in program
Run Code Online (Sandbox Code Playgroud)
任何帮助都会被证实,我确信它必须是简单的东西,但我是c的总菜鸟.
看起来有些人物可能通过Microsoft Word或类似程序"智能"化了.你需要做一个查找和替换改变“和”对"(或许也为其他字符,但“并”是唯一的字符抱怨的具体编译错误,你已经张贴).