不知道為什麼ubuntu文字變成了繁體。。淦。。。
有點蠢。。回來再改吧
1、猜數字
#include<iostream>
#include<ctime>
int main(){
srand((unsigned int)time(NULL));
int num = rand()%100+1;
bool flag = false;
int guess;
std::cout<<("请输入猜测值: ")<<std::endl;
while(flag != true){
std::cin >> guess;
if(guess==num){
flag = true;
std::cout<<("有点东西")<<std::endl;
}
else if (guess<num){
std::cout<<("小了")<<std::endl;
std::cout<<("再來: ")<<std::endl;
}
else {
std::cout<<("大了")<<std::endl;
std::cout<<("再來: ")<<std::endl;
}
}
}
2、水仙花數
#include<iostream>
#include<ctime>
#include <cmath>
using namespace std;
int main(){
int num =100;
do
{
int first = num%10;
int second = (num/10)%10;
int third = num/100;
if ((pow(first,3)+ pow(second,3) + pow(third,3)) == num)
{
cout<<num<<"是水仙花數"<<endl;
num++;
}
else
num++;
}
while(num<999);
}
3、敲桌子
#include<iostream>
#include<ctime>
#include <cmath>
using namespace std;
int main(){
int num =100;
do
{
int first = num%10;
int second = (num/10)%10;
int third = num/100;
if ((pow(first,3)+ pow(second,3) + pow(third,3)) == num)
{
cout<<num<<"是水仙花數"<<endl;
num++;
}
else
num++;
}
while(num<999);
}