一、函数
#include<stdio.h> //stdio.stdlib标准库
#include<stdlib.h> //代码重用, 函数的诞生,C语言主要是函数组成
//写C语言,就是写函数
//主要是代码重用,模块化(便于定位错误),
//函数就是对某一特定功能的抽象
void printfR(double R)
{
printf("体积=%f", / * 3.14*R*R*R);
printf("\n表面积=%f", * 3.14*R*R);
} void main123()
{
double R=;
printfR(R);
//printf("体积=%f", 4 / 3 * 3.14*R*R*R);
//printf("\n表面积=%f", 4 * 3.14*R*R); double R1 = ;
printfR(R1);
//printf("体积=%f", 4 / 3 * 3.14*R1*R1*R1);
//printf("\n表面积=%f", 4 * 3.14*R1*R1); double R2 = ;
printfR(R2);
//printf("体积=%f", 4 / 3 * 3.14*R2*R2*R2);
//printf("\n表面积=%f", 4 * 3.14*R2*R2); system("pause");
}
二、键盘
#include<stdio.h>
#include<stdlib.h>
#include<Windows.h> void main(){
//windows
//keybd_event(0x5b,0,0,0);//键盘按下Windows键
//keybd_event(0x5b,0,2,0);//键盘松开 //windows+R
//keybd_event(0x5b,0,0,0);//键盘按下Windows键
//keybd_event('E',0,0,0);//E按下
//keybd_event('E',0,2,0);//E松开
//keybd_event(0x5b,0,2,0);//键盘松开 //打开记事本
keybd_event(0x5b,,,);
keybd_event('R',,,);
keybd_event('R',,,);
keybd_event(0x5b,,,);
Sleep();
//需要提前把输入法设置为英文大写状态
keybd_event('N',,,);
keybd_event('N',,,);
keybd_event('O',,,);
keybd_event('O',,,);
keybd_event('T',,,);
keybd_event('T',,,);
keybd_event('E',,,);
keybd_event('E',,,);
keybd_event('P',,,);
keybd_event('P',,,);
keybd_event('A',,,);
keybd_event('A',,,);
keybd_event('D',,,);
keybd_event('D',,,);
Sleep();
keybd_event(0x0d,,,);//回车
keybd_event(0x0d,,,); Sleep();
exit();//退出
}
三、函数参数
#include<stdio.h> //参数会开辟一小段内存,接收一个新的变量
void change(int a){//形式参数,角色
a=;//给新开辟的内存赋值
printf("\nchange a=%x",&a);
} void main(){
int a=;
printf("main a=%x",&a);//地址不同,说明不是同一个变量
change(a);//实参,实际调用时刻的参数
printf("\n%d",a);
getchar();
}
四、调戏广告
1.打开百度 2.输入内容,回车 3.点击广告 4.结束退出(也可以无限循环)
#include<stdio.h>
#include<stdlib.h>
#include<Windows.h> void openbaidu(){
ShellExecuteA(,"open","http://www.baidu.com",,,);
} void close(){
system("taskkill /f /im 360se.exe");
} void search(){
keybd_event('X',,,);//按下
keybd_event('X',,,);//松开
keybd_event('I',,,);
keybd_event('I',,,);
keybd_event('A',,,);
keybd_event('A',,,);
keybd_event('N',,,);
keybd_event('N',,,);
keybd_event('H',,,);
keybd_event('H',,,);
keybd_event('U',,,);
keybd_event('U',,,);
keybd_event('A',,,);
keybd_event('A',,,);
Sleep();
//回车
keybd_event(0x0d,,,);
keybd_event(0x0d,,,);
}
void click(){
SetCursorPos(, );
mouse_event(MOUSEEVENTF_LEFTDOWN,,,,);
mouse_event(MOUSEEVENTF_LEFTUP,,,,);
SetCursorPos(, );
mouse_event(MOUSEEVENTF_LEFTDOWN,,,,);
mouse_event(MOUSEEVENTF_LEFTUP,,,,);
} void main(){
openbaidu();
Sleep();
search();
Sleep();
click();
Sleep();
close();
}
程序34行,设置鼠标点击位置需要用到一个软件
除此之外,要持续坑别人的广告费,还需要不断的更换IP地址,需要准备一个换IP工具