在線編譯試玩

github推出了在線編譯功能,

https://new.qq.com/omn/20200507/20200507A0B7CB00.html

 

這個估計要電腦性能和網絡良好的情況下才用得起來。

 

搜了下,有一些網站已經提供了在線編譯功能,對於單個源文件代碼的編譯來說,還是比較方便的

 

在沒有編譯器的電腦上,對單個文件的編譯,還是可以使用的,

測試了下https://tool.lu/coderunner/

可以進行編譯,還不錯

#include <iostream>
#include <malloc.h>

using namespace std;

char gstr[] = "abcaababbabcabbacc";

struct Node {
	Node* next;
	int pos;
};

Node* table[26][26][26] = {0};

void addNode(Node* head, int pos)
{
	while (head->next != NULL)
	{
		head = head->next;
	}
	
	Node* newNode = (Node*) malloc(1 * sizeof(Node));
	newNode->next = NULL;
	newNode->pos = pos;
	
	head->next = newNode;
}

void init(int len, char* str)
{
	for (int i = 0; i < len - 2; i++)
	{
		Node* head = table[gstr[i] - 'a'][gstr[i+1] - 'a'][gstr[i+2] - 'a'];
		if (head == NULL)
		{
			head = (Node*) malloc(1 * sizeof(Node));
			head->next = NULL;
			head->pos = i;
		}
		else
		{
			addNode(head, i);
		}
	}
}

int change(char* src, char* dst)
{
	int ret = 0;
	int pos = 0;
	Node* head = table[src[0] - 'a'][src[1] - 'a'][src[2] - 'a'];
	while (head != NULL)
	{
		if (head->pos >= pos)
		{
			gstr[head->pos] = dst[0];
			gstr[head->pos+1] = dst[1];
			gstr[head->pos+2] = dst[2];
			
			pos = head->pos + 3;
			ret++;
		}
	}
	
	return ret;
}

int main() {
	cout << "hello https://tool.lu/" << endl;
	return 0;
}

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章