You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.5 KiB

#include<iostream>
#include<string>
#include<cmath>
#include<sstream>
#include<graphics.h>
#include<conio.h>
std::string int_to_str(int n) {
std::stringstream ss;
std::string str;
ss << n;
ss >> str;
return str;
}
int str_to_num1(const char*& str) //转换类型
{
if (!(str[0] == '-' || (str[0] >= '0' && str[0] <= '9'))) {
return INT_MIN;
}
int n = 0;
while (str[n] != '\0') {
n++;
}
int number = 0;
if (str[0] != '-') {
for (int i = 0; i < n; i++) {
if (!(str[i] >= '0' && str[i] <= '9')) {
return INT_MIN;
}
number += (str[i] - '0') * pow(10, n - i - 1);
}
}
if (str[0] == '-') {
for (int i = 1; i < n; i++) {
if (!(str[i] >= '0' && str[i] <= '9')) {
return INT_MIN;
}
number += (str[i] - '0') * pow(10, n - i - 1);
}
number *= -1;
}
return number;
}
int str_to_num(const std::string& str) //转换类型
{
const char* data = str.c_str();
int number = str_to_num1(data);
return number;
}
// 无背景贴图
//void transparentimage3(IMAGE* dstimg, int x, int y, IMAGE* srcimg) //新版png
//{
// HDC dstDC = GetImageHDC(dstimg);
// HDC srcDC = GetImageHDC(srcimg);
// int w = srcimg->getwidth();
// int h = srcimg->getheight();
// BLENDFUNCTION bf = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
// AlphaBlend(dstDC, x, y, w, h, srcDC, 0, 0, w, h, bf);
//}
#pragma once