关于“找你妹”的C++实现

同系的一个女生这学期上程序设计基础,她的大作业选题是“用C++实现找你妹”,现在到期末了,大作业憋不出来,现恭请各位大牛支招……
主要问题如下:
1. 图形化界面用什么好?
2. 多线程操作如何实现?
如果各位有现成的代码的话,希望能提供参考一下!感激不尽!

C++,是 windows 编程、还是纯 C++ 编程呢?
如果是 Windows 编程,简单的用 GDI/GDI+ 来实现图形化界面就行;
如果是纯 C++(现成不太可能),需要用 C++ 的本身的图形图像处理函数,这个比较麻烦,工作量会很大

考虑到多线程,应该是我上述说的第一种情况。创建线程:CreateThread,想要几个线程就创建几个。关键在于线程的实现,同步等等机制。
现成的代码是不太可能了,建议你多去网上查找一下相关的东东。

天知道找你妹是个什么东西。能公布下这个出题老师所在的学校和姓名么?

或者你根本就是胡乱编造个故事,根本不是来问问题的。

  1. 图形化界面用什么好? 建议用cocos2d-x实现界面,跨平台的。

2.多线程操作如何实现?
C++11的标准库就有多线程实现了,下面给你一个示例

 #include <iostream>
#include <utility>
#include <thread>
#include <chrono>
#include <functional>
#include <atomic>

void f1(int n)
{
    for (int i = 0; i < 5; ++i) {
        std::cout << "Thread 1 executing\n";
        ++n;
        std::this_thread::sleep_for(std::chrono::milliseconds(10));
    }
}

void f2(int& n)
{
    for (int i = 0; i < 5; ++i) {
        std::cout << "Thread 2 executing\n";
        ++n;
        std::this_thread::sleep_for(std::chrono::milliseconds(10));
    }
}

int main(int, char**)
{
    int n = 0;
    std::thread t1; // t1 is not a thread
    std::thread t2(f1, n + 1); // pass by value
    std::thread t3(f2, std::ref(n)); // pass by reference
    std::thread t4(std::move(t3)); // t4 is now running f2(). t3 is no longer a thread
    t2.join();
    t4.join();
    std::cout << "Final value of n is " << n << '\n';
        return 0;
}

可能的输出

 Thread 1 executing
Thread 2 executing
Thread 1 executing
Thread 2 executing
Thread 1 executing
Thread 2 executing
Thread 1 executing
Thread 2 executing
Thread 2 executing
Thread 1 executing
Final value of n is 5
  1. 图形化界面用什么好? 建议用cocos2d-x实现界面,跨平台的。

2.多线程操作如何实现?
C++11的标准库就有多线程实现了,下面给你一个示例

 #include <iostream>
#include <utility>
#include <thread>
#include <chrono>
#include <functional>
#include <atomic>

void f1(int n)
{
    for (int i = 0; i < 5; ++i) {
        std::cout << "Thread 1 executing\n";
        ++n;
        std::this_thread::sleep_for(std::chrono::milliseconds(10));
    }
}

void f2(int& n)
{
    for (int i = 0; i < 5; ++i) {
        std::cout << "Thread 2 executing\n";
        ++n;
        std::this_thread::sleep_for(std::chrono::milliseconds(10));
    }
}

int main(int, char**)
{
    int n = 0;
    std::thread t1; // t1 is not a thread
    std::thread t2(f1, n + 1); // pass by value
    std::thread t3(f2, std::ref(n)); // pass by reference
    std::thread t4(std::move(t3)); // t4 is now running f2(). t3 is no longer a thread
    t2.join();
    t4.join();
    std::cout << "Final value of n is " << n << '\n';
        return 0;
}

可能的输出

 Thread 1 executing
Thread 2 executing
Thread 1 executing
Thread 2 executing
Thread 1 executing
Thread 2 executing
Thread 1 executing
Thread 2 executing
Thread 2 executing
Thread 1 executing
Final value of n is 5

清华我就呵呵了。

参考:http://news.qq.com/a/20100114/000203.htm
http://fj.sina.com.cn/news/p/p/2010-01-14/10219546.html
http://news.ifeng.com/society/2/201001/0113_344_1509034.shtml

用qt做比较好把,现在都流行用这个的。

感觉是不是 泡妞 被为难了 呢?