U1-11-单元复习(一)
原题链接:49776.蒟蒻队笔记汇总2025-10-26 12:10:04
发布于:江苏
一、数据类型回顾
#include <bits/stdc++.h>
using namespace std;
int main(){
//	double a[1005] = {}; 
//	int __123 = 0; 
	整数:
		short	// 2 Byte 
		int		// 4 Byte
		long long	//8 Byte 
	小数:
		double : 双精度 
			printf(".4lf", ans); 
			cout << fixed << setprecision(4) << ans << endl;//iomanip 
		float : 单精度 
	
	字符
	字符串 
	bool
	 
	return 0;
}
二、猜数字
#include <iostream>
#include <cstdlib> 
#include <ctime> 
using namespace std;
int main(){
	srand(time(0));	//设置随机数的种子 
	int ans =  rand()%1000+1; //(1, 1000) 
	int guess;
	while (1)
	{
		cout<<"请输入一个数字:(1~1000)"; 
		cin >> guess;
		if (guess > ans) cout << "大了\n";
		else if (guess < ans) cout << "小了\n";
		else {
			cout << "恭喜你,中奖了";
			break;
		} 
	}
	return 0;
}
三、火星计算
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n, a, b;
	char op;
	cin >> a >> n;
	for (int i=1; i<=n; i++){
		cin >> op >> b;
		if (op == '&'){
			a = a*b*b; 
		}
		if (op == '@'){
			a = a/b/b/b; 
		}
	} 
	cout << a;
	return 0;
}
这里空空如也








有帮助,赞一个