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 96 97 98 99 100 101 102 103 104 105
|
/* sin example */
#include <stdio.h> /* printf */
#include <math.h> /* sin */
#include <iostream>
#include <windows.h>
#define R 167
#define C 43
#define PI 3.14159265
#define V (char)0xB3
#define H (char)0xC4
#define P (char)0xC5
#define D (char)250
using namespace std;
char graph[R][C];
int y=0, x=0;
double X=0, Y=0;
int graphe(int, int ,int, int);
void grath();
int main ()
{
cout<<"This code only works properly in fullscreen mode."<<endl;
for(int i=0; i<C; i++){
for(int j=0; j<R; j++){
graph[j][i]=' ';
if(j==167){
graph[j][i]=0;
}
if(j==84)
graph[j][i]=V;
if(i==21){
graph[j][i]=H;
}
if(i==21&&j==84){
graph[j][i]=P;
}
};
}
cout<<"1. Y=Ax+B\n2. Y=A(Sin(x))\n3. Y=Ax²+Bx+C"<<endl;
int input1, a=0, b=0, c=0;
cin>>input1;
system("Cls");
switch(input1){
case 1:
cout<<" separated by a space, enter in the values for A and B.\t EXAMPLE: 2 6 (enter)"<<endl;
cin>>a;
cin>>b;
break;
case 2:
cout<<"please give the value for A"<<endl;
cin>>a;
break;
case 3:
cout<<"Wow. A quadratic. How original. I'm gonna need A, B, and C separated by spaces.\n EXAMPLE: 2 6 9"<<endl;
cin>>a;
cin>>b;
cin>>c;
break;
default:
cout<<"you suck. I hate you. Now you do not get anything. lol XD"<<endl;
return 0XD;
}
graphe(input1, a, b, c);
return 0;
}
int graphe(int type, int a, int b, int c){
if(type==1){
for(int i=0; i<C; i++, X++){
Y=a * X + b;
y=Y; x=X;
graph[y][x]=D;
}
}
else if(type==2){
for(int i=0, X=0; i<C; i++, X++){
Y=a*(sin(X));
x=X; y=Y;
graph[y][x]=D;
}
}
else if(type==3){
for(int i=0; i<C; i++, X++){
Y=a*(pow(X, 2))+b*X+c;
y=Y; x=X;
graph[y][x]=D;
}
}
grath();
return 1;
}
void grath(){
for(int i=0; i<=C; i++, x++){
for(int j=0; j<=R; j++){
cout<<graph[j][i];
}
cout<<endl;
}
}
|