码迷,mamicode.com
首页 > 编程语言 > 详细

[c/c++] programming之路(13)、函数

时间:2017-08-16 20:17:20      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:arch   cli   退出   状态   程序   class   百度   har   3.1   

一、函数

 1 #include<stdio.h>    //stdio.stdlib标准库
 2 #include<stdlib.h>
 3 
 4 //代码重用,    函数的诞生,C语言主要是函数组成
 5 //写C语言,就是写函数
 6 //主要是代码重用,模块化(便于定位错误), 
 7 //函数就是对某一特定功能的抽象
 8 void printfR(double R)
 9 {
10     printf("体积=%f", 4 / 3 * 3.14*R*R*R);
11     printf("\n表面积=%f", 4 * 3.14*R*R);
12 }
13 
14 void main123()
15 {
16     double R=6000;
17     printfR(R);
18     //printf("体积=%f", 4 / 3 * 3.14*R*R*R);
19     //printf("\n表面积=%f", 4 * 3.14*R*R);
20 
21     double R1 = 4000;
22     printfR(R1);
23     //printf("体积=%f", 4 / 3 * 3.14*R1*R1*R1);
24     //printf("\n表面积=%f", 4 * 3.14*R1*R1);
25 
26     double R2 = 350000;
27     printfR(R2);
28     //printf("体积=%f", 4 / 3 * 3.14*R2*R2*R2);
29     //printf("\n表面积=%f", 4 * 3.14*R2*R2);
30 
31     system("pause");
32 }

二、键盘

 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 #include<Windows.h>
 4 
 5 void main(){
 6     //windows
 7     //keybd_event(0x5b,0,0,0);//键盘按下Windows键
 8     //keybd_event(0x5b,0,2,0);//键盘松开
 9 
10     //windows+R
11     //keybd_event(0x5b,0,0,0);//键盘按下Windows键
12     //keybd_event(‘E‘,0,0,0);//E按下
13     //keybd_event(‘E‘,0,2,0);//E松开
14     //keybd_event(0x5b,0,2,0);//键盘松开
15 
16     //打开记事本
17     keybd_event(0x5b,0,0,0);
18     keybd_event(R,0,0,0);
19     keybd_event(R,0,2,0);
20     keybd_event(0x5b,0,2,0);
21     Sleep(1000);
22     //需要提前把输入法设置为英文大写状态
23     keybd_event(N,0,0,0);
24     keybd_event(N,0,2,0);
25     keybd_event(O,0,0,0);
26     keybd_event(O,0,2,0);
27     keybd_event(T,0,0,0);
28     keybd_event(T,0,2,0);
29     keybd_event(E,0,0,0);
30     keybd_event(E,0,2,0);
31     keybd_event(P,0,0,0);
32     keybd_event(P,0,2,0);
33     keybd_event(A,0,0,0);
34     keybd_event(A,0,2,0);
35     keybd_event(D,0,0,0);
36     keybd_event(D,0,2,0);
37     Sleep(1000);
38     keybd_event(0x0d,0,0,0);//回车
39     keybd_event(0x0d,0,2,0);
40 
41     Sleep(3000);
42     exit(0);//退出
43 }

 三、函数参数

 1 #include<stdio.h>
 2 
 3 //参数会开辟一小段内存,接收一个新的变量
 4 void change(int a){//形式参数,角色
 5     a=100;//给新开辟的内存赋值
 6     printf("\nchange a=%x",&a);
 7 }
 8 
 9 void main(){
10     int a=10;
11     printf("main a=%x",&a);//地址不同,说明不是同一个变量
12     change(a);//实参,实际调用时刻的参数
13     printf("\n%d",a);
14     getchar();
15 }

技术分享

技术分享

 四、调戏广告

1.打开百度  2.输入内容,回车  3.点击广告  4.结束退出(也可以无限循环)

 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 #include<Windows.h>
 4 
 5 void openbaidu(){
 6     ShellExecuteA(0,"open","http://www.baidu.com",0,0,3);
 7 }
 8 
 9 void close(){
10     system("taskkill /f /im 360se.exe");
11 }
12 
13 void search(){
14     keybd_event(X,0,0,0);//按下
15     keybd_event(X,0,2,0);//松开
16     keybd_event(I,0,0,0);
17     keybd_event(I,0,2,0);
18     keybd_event(A,0,0,0);
19     keybd_event(A,0,2,0);
20     keybd_event(N,0,0,0);
21     keybd_event(N,0,2,0);
22     keybd_event(H,0,0,0);
23     keybd_event(H,0,2,0);
24     keybd_event(U,0,0,0);
25     keybd_event(U,0,2,0);
26     keybd_event(A,0,0,0);
27     keybd_event(A,0,2,0);
28     Sleep(200);
29     //回车
30     keybd_event(0x0d,0,0,0);
31     keybd_event(0x0d,0,2,0);
32 }
33 void click(){
34     SetCursorPos(200, 300);
35     mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
36     mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
37     SetCursorPos(300, 300);
38     mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
39     mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
40 }
41 
42 void main(){
43     openbaidu();
44     Sleep(2000);
45     search();
46     Sleep(2000);
47     click();
48     Sleep(3000);
49     close();
50 }

程序34行,设置鼠标点击位置需要用到一个软件

技术分享

除此之外,要持续坑别人的广告费,还需要不断的更换IP地址,需要准备一个换IP工具

技术分享

 

[c/c++] programming之路(13)、函数

标签:arch   cli   退出   状态   程序   class   百度   har   3.1   

原文地址:http://www.cnblogs.com/little-monkey/p/7306409.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!