所以我有一个函数(或者更确切地说,我稍后将其转换为函数)以在控制台窗口中进行随机%进度; 像这样:
#include <iostream>
#include <time.h>
#include <cmath>
#include <windows.h>
using namespace std;
int main()
{
srand(time(0));
int x = 0;
for(int i = 0; i<100; i++){
int r = rand() % 1000;
x++;
cout << "\r" << x << "% completed." << flush;
if(i < 43){
Sleep(r/6);
}else if(i > 43 && i < 74){
Sleep(r/8);
}else if(i < 98){
Sleep(r/5);
}else if(i > 97 && i != 99){
Sleep(2000);
}
}
cout << endl << endl << "Operation …Run Code Online (Sandbox Code Playgroud) 我正在使用这个正则表达式来测试用户名是否有效:
[A-Za-z0-9 _]{3,12}当我在文本编辑器中使用 string 测试匹配时test'ing,它会突出显示“test”和“ing”,但是当我在 PHP 中使用以下代码时:
if(!preg_match('/[A-Za-z0-9 _]{3,12}/', $content)$content 在哪里test'ing,它应该返回 FALSE,它仍然返回 true。
我的正则表达式有问题吗?我需要:
{3,12}[A-Za-z0-9 _]提前致谢...
我在想知道是否存在PHP混淆器后才看到此线程。它给了我一个问题:
如果一开始就不应该将PHP文件下载/“反编译”,为什么需要混淆PHP代码?
这一定是一个问题很多,但我找不到我想要的东西.
想象一下:
你继续输入一个数字并继续得到这个错误,而在后台它只是跟踪程序运行了多长时间,通过每秒做一次n ++,无论文本/输入部分发生了什么.最终你可以输入类似"时间"的东西,然后它显示你在那里待了多久,在几秒钟内...
所以我的问题是:你到底该怎么做呢?让它们独立运行?
提前致谢!
编辑:我不是特别试图做这个计时的事情,这只是我能想出的关于独立运行函数的最简单的例子.
string banana = "banana apple";
banana.Replace("apple", "pie");
Run Code Online (Sandbox Code Playgroud)
如果我想用饼替换苹果,我可以这样做,还是需要使用以下?
if(banana.Contains("apple"))
banana.Replace("apple", "pie");
Run Code Online (Sandbox Code Playgroud) 获取错误:跨线程操作无效:控制'label1'从其创建的线程以外的线程访问.
码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
string CONNECTING = "Connecting to server...";
string GETTING_DATA = "Getting data...";
string CONNECT_FAIL = "Failed to connect!";
string CONNECT_SUCCESS = "Connection established!";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Thread t1 = new Thread(run);
t1.Start();
}
public void run() {
label1.Text = CONNECTING; …Run Code Online (Sandbox Code Playgroud) WHYYYYYYY?
以下是我的一半代码,因为我已经删除了大部分代码以及我在尝试解决此问题时丢失的每一根头发.无论我删除或更改什么,我都会收到StackOverflowException.
这是非常奇怪的,因为这个完全相同的代码更早.
请给我任何建议,因为我很无能为力......
我检查了这个,我不认为这是发生的事情:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Net;
namespace ConsoleApplication10
{
class Program
{
public int currentDialogueID = 0;
List<NPC> NPCList = new List<NPC>() {
new NPC(0, "Man", 1, true),
new NPC(1, "Woman", 1, true),
new NPC(2, "Troll", 3, true)
};
static void Main(string[] args)
{
Program d = new Program();
d.Init();
Console.ReadKey(false);
}
void Init()
{
getNPCByName("Man").NPCDialogue();
}
public NPC getNPCByName(string npcName)
{
IEnumerable<NPC> myNPCsName …Run Code Online (Sandbox Code Playgroud) c# ×3
c++ ×2
php ×2
contains ×1
cout ×1
obfuscation ×1
preg-match ×1
progress-bar ×1
regex ×1
replace ×1
string ×1
time ×1
variables ×1
web ×1
windows ×1