当前位置: 首页 > news >正文

你好,复变函数2.0

 

 第一行:0 或 1

 第二行:(空格)+函数(后缀)

#pragma warning(disable:4996)
#include <easyx.h>
#include <stdio.h>
#include <math.h>
#define PI 3.141592653589793
#define E  2.718281828459045
#define K  (1.0 / 256.0)
#define K_1 256.0
struct C {double i;double r;C operator = (C n) {i = n.i; r = n.r;return C({ i, r });}C operator + (C n) {return C({ i + n.i, r + n.r });}C operator - (C n) {return C({ i - n.i, r - n.r });}C operator * (C n) {return C({ r * n.i + i * n.r, r * n.r - i * n.i});}C operator / (C n) {return C({(i * n.r - r * n.i) / (n.i * n.i + n.r * n.r),(i * n.i + r * n.r) / (n.i * n.i + n.r * n.r)});}void print() {printf("%lfi%+lf", i, r);}
};
int top = 0;
int len = 0;
int _line;
int p[4096][2];
char str[512];
C stack[512];
void getnum(int l) {bool k = false;double x = 1.0;stack[top] = C({ 0, 0 });for (int i = l; str[i] != ' ' && str[i] != '\0'; i++) {if (k) x *= 10;if (str[i] != '.')stack[top] = stack[top] * C({ 0, 10 }) + C({ 0, double(str[i] - '0') });else k = true;}stack[top] = stack[top] / C({ 0, x });top++;
}
void del(C c) {for (int i = 0; str[i] != '\0'; i++) {if (str[i] == ' ') {i++;if (str[i] >= '0' && str[i] <= '9')getnum(i);if (str[i] == 'e')stack[top++] = C({ 0, E });if (str[i] == 'x')stack[top++] = c;if (str[i] == '+') {top--;stack[top - 1] = stack[top - 1] + stack[top];}if (str[i] == '-') {top--;stack[top - 1] = stack[top - 1] - stack[top];}if (str[i] == '*') {top--;stack[top - 1] = stack[top - 1] * stack[top];}if (str[i] == '/') {top--;stack[top - 1] = stack[top - 1] / stack[top];}if (str[i] == '^') {top--;if (stack[top - 1].i == 0) {C c;c.r = cos(log(pow(stack[top - 1].r, stack[top].i))) * pow(stack[top - 1].r, stack[top].r);c.i = sin(log(pow(stack[top - 1].r, stack[top].i)));stack[top - 1] = c;}else if (stack[top].i == 0) {
#define A(x, y) (sqrt((x) * (x) + (y) * (y)))C c;c.r = pow(A(stack[top - 1].i, stack[top - 1].r), stack[top].r) * cos(stack[top].r * asin(stack[top - 1].i / A(stack[top - 1].i, stack[top - 1].r)));c.i = pow(A(stack[top - 1].i, stack[top - 1].r), stack[top].r) * sin(stack[top].r * asin(stack[top - 1].i / A(stack[top - 1].i, stack[top - 1].r)));stack[top - 1] = c;
#undef A}else {MessageBox(NULL,L"暂不支持此运算",  L"Error", MB_OK);}}}}p[len][0] = 512 + int(stack[0].r * K_1 + 0.5);p[len][1] = 512 - int(stack[0].i * K_1 + 0.5);if (_line == 0)putpixel(p[len][0], p[len][1], RGB(0, 255, 255));len++;
}
int main() {initgraph(1024, 1024, EX_SHOWCONSOLE);setlinecolor(RGB(0, 255, 255));scanf("%d", &_line);getchar();gets_s<512>(str);for (int y = -1024; y < 1024; y += 16) {len = 0;for (int x = -1024; x < 1024; x += 1) {top = 0;C c = { y * K, x * K };del(c);}if (_line == 1)for (int i = 0; i < len - 1; i++) {line(p[i][0], p[i][1], p[i + 1][0], p[i + 1][1]);}}for (int y = -1024; y < 1024; y += 16) {len = 0;for (int x = -1024; x < 1024; x += 1) {top = 0;C c = { x * K, y * K };del(c);}if (_line == 1)for (int i = 0; i < len - 1; i++) {line(p[i][0], p[i][1], p[i + 1][0], p[i + 1][1]);}}saveimage(L"1.jpg");printf("--------\n");getchar();closegraph();
}

http://www.lryc.cn/news/380952.html

相关文章:

  • 汉语拼音字母表 (声母表和韵母表)
  • C++20中的Feature Test Mocros
  • 运维iptables与firewalld详解
  • 适用于 Android 的 几种短信恢复应用程序
  • Lodash-js工具库
  • Makefile实战论(一)
  • Hi3861 OpenHarmony嵌入式应用入门--PWM 三色灯
  • CH5xx USB下载工具
  • 问题1.用PGP解密出keybox.xml,过程中报“Can‘t check signature: No public key”如图,这个正常吗?如何解决?
  • 网络物理隔离后 可以用保密U盘进行数据安全交换吗?
  • 机械臂 CoppeliaSim Simulink联合仿真
  • MySQL数据库(一):数据库介绍与安装
  • 天津媒体邀约,及媒体名单?
  • Java | Leetcode Java题解之第168题Excel表列名称
  • 代码随想录算法训练营刷题复习10:二叉树、二叉搜索树复习2
  • 预测准确率达95.7%,ChatMOF利用LLM预测和生成金属有机框架,包含人工智能词汇表(AI glossary)
  • 【Linux】环境基础开发工具使用(yum、vim、gcc/g++、gdb、make/Makefile)
  • Linux基础二
  • Linux运维面试--yum安装和编译安装区别
  • redis 的内存尽量不要超过 10g,超过 10g 可能会有问题
  • 力扣(2024.06.23)
  • OpenCV颜色检测
  • VScode开发ARM环境搭建
  • AI-人工智能指数报告(四):科学、医学与教育
  • Redis内存数据库
  • LabVIEW高精度电能质量监测系统
  • Java程序之可爱的小兔兔
  • ▶《强化学习的数学原理》(2024春)_西湖大学赵世钰 Ch5 蒙特卡洛方法【model-based ——> model-free】
  • 【linux】Valgrind工具集详解(十六):交叉编译、移植到arm(失败)
  • 前端面试题(七)答案版