随笔分类 -  循环结构

摘要:#include<bits/stdc++.h> using namespace std; int main() { int n,ans = 0; //ans次数 cin >> n; while(n != 495) { int a = n % 10; //个位 int b = n / 10 % 10; 阅读全文
posted @ 2024-10-23 14:25 CRt0729 阅读(14) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> using namespace std; // n % 10 得到n的个位数 // n / 10 去除n的个位数 //1.不断的分割出一个数的个位数 //2.当分割的数不为零,执行循环 int main() { int n,sum = 0; cin > 阅读全文
posted @ 2024-10-23 14:25 CRt0729 阅读(7) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int sum = 0; //统计位数 while(n != 0) { sum++; n /= 10; //每分割一位数就统计位数+1 } cout 阅读全文
posted @ 2024-10-23 14:22 CRt0729 阅读(5) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> using namespace std; int main() { int n;cin >> n; int ans = 0,k = 0,h = 1; //ans当前前进的距离,k天数,h是一次可以前进的距离 while(ans < n) { ans + 阅读全文
posted @ 2024-10-23 14:20 CRt0729 阅读(3) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> using namespace std; int main() { int minn = 9999999,i = 1,n; //最小值minn,循环变量i cin >> n; while(i <= n) //i=1时,写i<=n可以实现循环n次 { i 阅读全文
posted @ 2024-10-23 14:04 CRt0729 阅读(20) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> using namespace std; int main() { int maxx = 0,i = 1,n = 5; //最大值maxx,循环变量i while(i <= n) //i=1时,写i<=n可以实现循环n次 { int x; cin >> 阅读全文
posted @ 2024-10-23 14:02 CRt0729 阅读(5) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> using namespace std; int main() { int i = 1,n,maxx = -9999999; //初始化最大值maxx为负数 cin >> n; while(i <= n) { int x; cin >> x; if(x 阅读全文
posted @ 2024-10-23 13:37 CRt0729 阅读(15) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> using namespace std; int main() { int sum = 0,i = 1,n; //求和sum,循环变量i cin >> n; while(i <= n) //i=1时,写i<=n可以实现循环n次 { int x; cin 阅读全文
posted @ 2024-10-23 13:37 CRt0729 阅读(8) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> using namespace std; int main() { int sum = 0,i = 1,n; //求和sum,循环变量i cin >> n; while(i <= n) //i=1时,写i<=n可以实现让i从1到n变化 { sum = 阅读全文
posted @ 2024-10-23 13:35 CRt0729 阅读(5) 评论(0) 推荐(0) 编辑
摘要:循环结构参考资料:https://blog.csdn.net/m0_56945138/article/details/118929416需要掌握:1.for循环用法2.while循环用法3.continue跳过 和 break终止 题号 题目名称 题解链接 3067 输出范围内的整数 https:/ 阅读全文
posted @ 2024-06-30 22:58 CRt0729 阅读(14) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> #define f(i,s,e) for(int i = s; i <= e; i++) #define ll long long using namespace std; const int N = 1e3+10,inf = 0x3f3f3f3f; 阅读全文
posted @ 2024-06-28 18:00 CRt0729 阅读(13) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int sum = 0; for(int i = 1;i <= n;i++) { int x; cin >> x; sum += x; //把每一个输 阅读全文
posted @ 2024-06-28 17:59 CRt0729 阅读(68) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> #define f(i,s,e) for(int i = s; i <= e; i++) #define ll long long using namespace std; const int N = 1e3+10,inf = 0x3f3f3f3f; 阅读全文
posted @ 2024-06-28 17:58 CRt0729 阅读(25) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> #define f(i,s,e) for(int i = s; i <= e; i++) #define ll long long using namespace std; const int N = 1e3+10,inf = 0x3f3f3f3f; 阅读全文
posted @ 2024-06-28 17:56 CRt0729 阅读(15) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> #define f(i,s,e) for(int i = s; i <= e; i++) #define ll long long using namespace std; const int N = 1e3+10,inf = 0x3f3f3f3f; 阅读全文
posted @ 2024-06-28 17:55 CRt0729 阅读(10) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> #define f(i,s,e) for(int i = s; i <= e; i++) #define ll long long using namespace std; const int N = 1e3+10,inf = 0x3f3f3f3f; 阅读全文
posted @ 2024-06-28 17:52 CRt0729 阅读(79) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> #define f(i,s,e) for(int i = s; i <= e; i++) #define ll long long using namespace std; const int N = 1e3+10,inf = 0x3f3f3f3f; 阅读全文
posted @ 2024-06-28 17:51 CRt0729 阅读(24) 评论(0) 推荐(0) 编辑
摘要:我比较喜欢解法二的for 解法1:while循环 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e3+10,inf = 0x3f3f3f3f; int main() { int n, 阅读全文
posted @ 2024-06-28 17:47 CRt0729 阅读(11) 评论(0) 推荐(0) 编辑
摘要:主要就是让你学会如何循环范围、奇数范围、偶数范围 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e3+10,inf = 0x3f3f3f3f; int main() { for(in 阅读全文
posted @ 2024-06-28 17:45 CRt0729 阅读(39) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示