2019年3月6日 CPP

实验一:

C++的一些基本输入

实验二:

用C++判断一个数是不是素数

实验三:

求一个数字分解成每一位数字的和

模拟银行账户(写得比较傻)

//#include<iostream>
//using namespace std;
//void main()
//{
//	char name[20];
//	int age;
//	cout << "What is your name and age?" << endl;
//	cin >> name >> age;
//	cout << "Hello " << name << "." << endl<< "Your age is " << age<<endl;
//}
//
//#include<iostream>
//using namespace std;
//
//bool isprime(int n) {
//	bool flag = 1;
//	if (n == 2)	return flag;
//	else if (n % 2 == 0 || n == 1)	return 0;
//	else {
//		for (int i = 3; i < sqrt(n); i += 2) {
//			if (n % i == 0) return 0;
//		}
//		return 1;
//	}
//}
//int main()
//{
//	cout << "请输入一个数" << endl;
//	int num;
//	cin >> num;
//	if(isprime(num))	cout << "这个数是素数" << endl;
//	else cout << "这个数不是素数" << endl;
//}

//#include<iostream>
//using namespace std;
//int main()
//{
//	char a[100];
//	gets_s(a);
//	int sum = 0;
//	for (int i = 0; i < strlen(a); i++)
//		sum += a[i] - '0';
//	cout << sum << endl;
//	
//}


#include<iostream>
using namespace std;
int main()
{
	int account , password;
	cout << "请输入账号:" << endl;
	cin >> account;
	cout << "请输入密码:" << endl;
	cin >> password;
	if (account == 123 && password == 123456)	cout << "登陆成功" << endl;
	else cout << "登陆失败";
}

猜你喜欢

转载自blog.csdn.net/qq_43591782/article/details/88235442
cpp