0
我使用了我的程序并缩写了一些部分。不过我不确定它是否算作伪代码。这里是。如何将其更改为伪代码
#include "mbed.h"
const int BUFFERSIZE = 1024;
int buffer[BUFFERSIZE];
int UTC[10];
int lat[10];
int ns;
int lon[10];
int ew;
int posfix;
int numsats[2];
Serial pc(p9, p10);
Serial gps(p13, p14);
int findStart(int pos)
{
for(int i = pos; i < BUFFERSIZE; i++)
{
if buffer[pos to pos+5] == “$GP”
return pos + 5;
else
return BUFFERSIZE;
}
return BUFFERSIZE;
}
bool code(int pos, char c[3])
{
if(buffer[pos to pos + 2]==c)
return true;
else
return false;
return false;
}
void loadVariables(int pos)
{
assign variables based on relative position to pos
}
void displayVariables()
{
for every variable
print description + value;
}
void parsebuffer()
{
int pos = 0; // current read position in the buffer
while (pos < BUFFERSIZE - 1)
{
pos = findStart(pos);
if(pos > BUFFERSIZE - 50) return;
bool codeknown = true;
if (found “GGA”)
{
pc.printf("Found GGA\r\n");
loadVariables(pos+3);
displayVariables();
}
else if (found “GLL”)
{
pc.printf("Found GLL\r\n");
}
else
codeknown = false;
if(!codeknown)
print code found
}
}
int main() {
pc.baud(4800);
pc.format(8,Serial::None,1);
gps.baud(4800);
gps.format(8,Serial::None,1);
pc.putc(0x0c);
while(1) {
put data from GPS into array
parsebuffer();
pc.printf("\r\npress a key to continue\r\n");
pc.getc();
}
}
这是一个很大的问题。 – 2011-05-16 13:11:21
这可能会让你对伪代码有所了解http://www.coderookie.com/2006/tutorial/the-pseudocode-programming-process/ – 2011-05-16 13:15:16
伪代码对于我来说可能意味着几种不同的东西:“这里有些代码看起来很模糊,明确了程序的意图,但不能在任何地方的任何编译器中进行编译“to”这里是过程中每个原子部分的一些英文文本描述,例如'遍历价格阵列中的所有值并将它们打印到屏幕上'“。你可能想澄清你的意思是伪代码,为什么你想要它。 – Chris 2011-05-16 13:19:16