loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.8616666577560468","path":"main.c","file":{"path":"main.c","content":{"asEncoding":{"base64":"I2RlZmluZSBQIDQ1CiNkZWZpbmUgTSAxNjAgCiNkZWZpbmUgTiA5MAojaW5jbHVkZSA8bWF0aC5oPgojaW5jbHVkZSA8c3RkbGliLmg+CiNpbmNsdWRlIDxzdGRpby5oPgoKc3RydWN0IHBvaW50IHsKICBkb3VibGUgeCwgeTsKfTsKCnN0cnVjdCBwb2ludCB2YWxzW1BdOwpjaGFyICAgICAgICAgc2NyZWVuW05dW01dOwoKZG91YmxlIGZ1bmN0aW9uKGRvdWJsZSB4KQp7CiAgcmV0dXJuIChmYWJzKHgpK3gtMik7Cn0KCmludCBuZWFyZXN0KGRvdWJsZSB4KQp7CiAgcmV0dXJuICgoaW50KSAoeCswLjUpKTsKfQoKdm9pZCBjbGVhcl9zY3JlZW4oKSAgICAgICAgICAgIAp7CglpbnQgaSxqOwoJZm9yKGk9MDtpPE47aSsrKQoJCWZvcihqPTA7ajxNO2orKykKCQkJc2NyZWVuW2ldW2pdPScgJzsKfQoKdm9pZCBwbG90X3NjcmVlbigpCnsKCWludCBpLGo7Cglmb3IoaT1OLTE7aT49MDtpLS0pCgl7CgkJZm9yKGo9MDtqPE07aisrKQoJCQlwcmludGYoIiVjIixzY3JlZW5baV1bal0pOwoJCXByaW50ZigiXG4iKTsKCX0KfQoKdm9pZCBjYWxjdWxhdGVfdmFsdWVzKGRvdWJsZSBsLCBkb3VibGUgcikKewoJaW50IGk7Cglmb3IoaT0wO2k8UDtpKyspCgl7CgkJdmFsc1tpXS54PWwraSooci1sKS8oUC0xKTsKCQl2YWxzW2ldLnk9ZnVuY3Rpb24obCtpKihyLWwpLyhQLTEpKTsKCX0KfQoKdm9pZCBob3Jpem9udGFsKGludCByb3cpCnsKCWludCBqOwoJZm9yKGo9MDtqPE07aisrKQoJCXNjcmVlbltyb3ddW2pdPSctJzsKfQoKdm9pZCB2ZXJ0aWNhbChpbnQgY29sKQp7CglpbnQgaTsKCWZvcihpPTA7aTxOO2krKykKCQlzY3JlZW5baV1bY29sXT0nfCc7Cn0KCnZvaWQgbWFwX3RvX3NjcmVlbihkb3VibGUgbCwgZG91YmxlIHIsIGRvdWJsZSBkLCBkb3VibGUgdSkKewoJaW50IGksaixpMTsKCWRvdWJsZSB4LHk7CglpZihsPD0wJiYwPD1yKQoJCWhvcml6b250YWwoLWQqKE4tMSkvKHUtZCkpOwogICAgaWYoZDw9MCYmMDw9dSkKCQl2ZXJ0aWNhbCgtbCooTS0xKS8oci0xKSk7Cglmb3IoaTE9MDtpMTxOO2kxKyspCgl7CgkJeD12YWxzW2kxXS54OwoJCXk9dmFsc1tpMV0ueTsKCQlpPSgoeS1kKSooTi0xKSkvKHUtZCk7CgkJaj0oKHgtbCkqKE0tMSkpLyhyLWwpOwoJCWlmKG5lYXJlc3QoaSk+PTAmbmVhcmVzdChpKTxOLTEmJm5lYXJlc3Qoaik+PTAmJm5lYXJlc3Qoaik8TS0xKQoJCQlzY3JlZW5baV1bal09Jy4nOwoJfQp9CgppbnQgbWFpbigpCnsKICBjbGVhcl9zY3JlZW4oKTsKICBjYWxjdWxhdGVfdmFsdWVzKC01LCA1LjApOwogIG1hcF90b19zY3JlZW4oLTUuMCwgNS4wLCAtNS4wLCAxMC4wKTsKICBwbG90X3NjcmVlbigpOwogIHN5c3RlbSgiUEFVU0UiKTsKICByZXR1cm4gMDsKfQ=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#define P 45
#define M 160 
#define N 90
#include <math.h>
#include <stdlib.h>
#include <stdio.h>

struct point {
  double x, y;
};

struct point vals[P];
char         screen[N][M];

double function(double x)
{
  return (fabs(x)+x-2);
}

int nearest(double x)
{
  return ((int) (x+0.5));
}

void clear_screen()            
{
	int i,j;
	for(i=0;i<N;i++)
		for(j=0;j<M;j++)
			screen[i][j]=' ';
}

void plot_screen()
{
	int i,j;
	for(i=N-1;i>=0;i--)
	{
		for(j=0;j<M;j++)
			printf("%c",screen[i][j]);
		printf("\n");
	}
}

void calculate_values(double l, double r)
{
	int i;
	for(i=0;i<P;i++)
	{
		vals[i].x=l+i*(r-l)/(P-1);
		vals[i].y=function(l+i*(r-l)/(P-1));
	}
}

void horizontal(int row)
{
	int j;
	for(j=0;j<M;j++)
		screen[row][j]='-';
}

void vertical(int col)
{
	int i;
	for(i=0;i<N;i++)
		screen[i][col]='|';
}

void map_to_screen(double l, double r, double d, double u)
{
	int i,j,i1;
	double x,y;
	if(l<=0&&0<=r)
		horizontal(-d*(N-1)/(u-d));
    if(d<=0&&0<=u)
		vertical(-l*(M-1)/(r-1));
	for(i1=0;i1<N;i1++)
	{
		x=vals[i1].x;
		y=vals[i1].y;
		i=((y-d)*(N-1))/(u-d);
		j=((x-l)*(M-1))/(r-l);
		if(nearest(i)>=0&nearest(i)<N-1&&nearest(j)>=0&&nearest(j)<M-1)
			screen[i][j]='.';
	}
}

int main()
{
  clear_screen();
  calculate_values(-5, 5.0);
  map_to_screen(-5.0, 5.0, -5.0, 10.0);
  plot_screen();
  system("PAUSE");
  return 0;
}