PX-8-c语言的编程流程

1.打开关闭 qq

#define  _CRT_SECURE_NO_WARNINGS
#include<stdlib.h>
#include<windows.h>
#include<stdio.h>

void open()
{
    //start不能带路径,需要提前进入目录
   system(" \"C:\\Program Files (x86)\\Tencent\\QQ\\QQProtect\\Bin\\QQProtect.exe\"");
}

void openqq()
{
    ShellExecuteA(0, "open", "\"C:\\Program Files (x86)\\Tencent\\QQ\\QQProtect\\Bin\\QQProtect.exe\"", 0, 0, 1);

    //ShellExecuteA(0, "open", "notepad", 0, 0, 6);
    //0隐藏,1正常,3最大化,6最小化
}

void close()
{
   system("taskkill /f  /im QQ.exe");
}

void times()
{
     int num=0;
     scanf("%d",&num);
     int i=0;
     while(i<num)//i《m不再循环
    { 

       Sleep(1000);
       i++;
       printf("%d", i);
     }

}

void main()
{
    //openqq();
    open();
    times();
  
     close();
}

 

2.倒计时10s 打开关闭记事本

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

void opennotepad()
{
    system("start notepad");
}

void time() 
{
    int num = 0;
    scanf("%d" , &num);

    int i = 0;
    while (i < num ) {    
        Sleep(1000);
        i++;
        printf("%d", num - i);
    }
}

void closenote()
{
    system("taskkill /f /im  notepad.exe");

}

void main() 
{
    opennotepad();
    time();
    closenote();
}

3.跨平台时候 没有 windows.h时的报错原因 , windows2015 开发工具编译时候的路径错误

 

posted @ 2016-12-09 15:46  silvercell  阅读(2678)  评论(0)    收藏  举报