[C++ && Python]简单模拟代码评测系统
来源:互联网 发布:苹果蓝牙共享网络 编辑:程序博客网 时间:2024/06/02 06:56
简单模拟代码评测系统
本实现版本使用python调用系统命令(compiler.py)完成代码的编译,输入,输出,用judge.cpp程序判断测试文件与标准程序之间的输入是否有差别,从而判断是否为正确程序代码。但这里还有一个问题,就是没有随机生成的输入内容,这个部分需要自己编写。此程序大概简化模拟了eden评测系统的原理。对于平时研究自己的代码与网络代码之间的正确与否有一定的帮助。
代码下载
核心代码
import osos.system("g++ Standard.cpp -o Standard")os.system("g++ test.cpp -o test")os.system("./Standard < input > output_Standard")os.system("./test < input > output_answer")os.system("g++ judge.cpp -o judge")os.system("./judge")
#include <iostream>#include <string>#include <fstream>#include <string.h>#include <stdlib.h>using namespace std;int main(int argc, char const *argv[]){ string standard; ifstream file_Standard ("output_Standard"); if (!file_Standard.is_open()) { cout << "fail" << endl; } ifstream file_answer ("output_answer"); char Standard_answer[100]; char Test_answer[100]; while (!file_answer.eof()) { file_Standard.getline(Standard_answer, 100); file_answer.getline(Test_answer, 100); if (strcmp(Standard_answer, Test_answer)) { cout << Standard_answer << endl; cout << Test_answer << endl; cout << "wrong" << endl; return 0; } } cout << "true" << endl; return 0;}
测试代码
#include <iostream>#include <map>#include <set>using namespace std;int main() { multimap<string, string> Q; int n; cin >> n; while (n--) { string input1, input2; cin >> input1 >> input2; if (Q.find(input1) == Q.end() || Q.find(input1)->second != input2) { Q.insert(make_pair(input1, input2)); } } string address; cin >> address; multimap<string, string>::iterator iter = Q.begin(); int flag = 0; while (iter != Q.end()) { if (iter->second == address) { flag = 1; break; } iter++; } iter = Q.begin(); if (flag == 1) { cout << address; cout << " ==> [ "; multimap<string, string>::iterator iters = Q.begin(); set<string> answer; while (iters != Q.end()) { if (iters->second == address) { answer.insert(iters->first); } iters++; } for (set<string>::iterator iter = answer.begin(); iter != answer.end(); iter++) { cout << *iter << " "; } cout << "]" << endl; } else { cout << "no Q" << endl; } string number; cin >> number; if (Q.find(number) != Q.end()) { cout << number; cout << " ==> [ "; multimap<string, string>::iterator iterss = Q.begin(); set<string> answer; while (iterss != Q.end()) { if (iterss->first == number) { answer.insert(iterss->second); } iterss++; } for (set<string>::iterator iter = answer.begin(); iter != answer.end(); iter++) { cout << *iter << " "; } cout << "]" << endl; } else { cout << "no ip" << endl; } return 0;}
#include <iostream>#include <map>#include <set>#include <string>using namespace std;int main() { map<string, set<string> > ip2qq; map<string, set<string> > qq2ip; int n; string Q, ip; cin >> n; while (n--) { cin >> Q >> ip; ip2qq[ip].insert(Q); qq2ip[Q].insert(ip); } map<string, set<string> >::iterator it; set<string>::iterator its; cin >> ip; if (ip2qq.find(ip) == ip2qq.end()) { cout << "no Q" << endl; } else { cout << ip << " ==> [ "; for (its = ip2qq[ip].begin(); \ its != ip2qq[ip].end(); its++) { cout << *its << " "; } cout << "]" << endl; } cin >> Q; if (qq2ip.find(Q) == qq2ip.end()) { cout << "no ip" << endl; } else { cout << Q << " ==> [ "; for (its = qq2ip[Q].begin(); \ its != qq2ip[Q].end(); its++) { cout << *its << " "; } cout << "]" << endl; } return 0;}
output_Standard
192.168.1.45 ==> [ 10258279640 10258279649 ]10258279649 ==> [ 192.168.1.45 ]
output_answer
192.168.1.45 ==> [ 10258279640 10258279649 ]10258279649 ==> [ 192.168.1.45 ]
input
510258279649 192.168.1.4510258279649 192.168.1.4510258279643 192.168.1.410258279640 192.168.1.4510258279641 192.168.1.30192.168.1.4510258279649
0 0
- [C++ && Python]简单模拟代码评测系统
- 代码执行时间评测系统
- 模拟银行叫号系统(c代码)
- 开源评测系统hustoj-代码解读
- python代码简单模拟Java中的MVC设计
- 一个简单的C代码,模拟洗牌发牌
- 学生信息管理系统简单模拟(C语言实现)
- 在线云评测系统日志(七):后台从数据库中取出待评测代码
- 开源评测系统hustoj-代码解读1
- 开源评测系统hustoj-代码解读 及 快速安装
- ACM在线测评系统评测程序设计与python实现
- ACM在线测评系统评测程序设计与python实现
- ACM在线测评系统评测程序设计与python实现
- CCF中学生程序设计在线评测系统(C語言練習用)
- python简单模拟数据库程序
- Python 模拟简单的queue
- python实现ZOJ1745(简单模拟)
- python简单模拟登陆详解
- [js]关于闭包与访问数组下标的老生常谈
- 【技术架构】负载均衡算法
- 使用MEAN进行现代化WEB开发
- JAVA 访问MySQL数据库(使用方法及测试)
- 希望在这里学到更多
- [C++ && Python]简单模拟代码评测系统
- select(poll)实现代码实现分析(基于kernel 3.10.0)
- mysql基础使用浅谈(1)
- jQuery cookie操作
- ViewPager实现无限循环
- 面向对象软件设计遵循的原则
- 系统开启桌面小部件支持
- Java EE中事务处理
- BP神经网络设计常用的基本方法和实用技术