2
8
36
新手上路
使用道具 举报
#include<bits/stdc++.h> int a=1,b=2; int t; void SWAP(){ t=a;a=b;b=t } void test(int&a,&b){ a=a+1,b=b+1; } int mai(){ cout<<a<<' '<<b<<endl; int a=10,b=20; SWAP();test(a,b); cout<<a<<' '<<b; }[mw_shl_code=c,true]
#include<bits/stdc++.h> int a=1,b=2; int t; void SWAP(){ t=a;a=b;b=t } void test(int&a,&b){ a=a+1,b=b+1; } int main(){ cout<<a<<' '<<b<<endl; int a=10,b=20; SWAP();test(a,b); cout<<a<<' '<<b; }
#include <bits/stdc++.h> using namespace std; int main() { int m; int n; int sum=0; scanf("%d %d",m,n); for(int i=m;i<=n;i++) { if(i%2==1)//i=i+2; sum=sum+i; } printf("%d",sum); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int m; scanf("%d",&m); printf("%d",m); if(m<=0||m>11){ printf("输入错误:\n"); return 1; } double sum=0.0; int n=1; while(sum<m){ sum+=1.0/n; n++; } printf("满足不等式最小的n值为:/n"); printf("n=%d"); return 0; }
574
758
243万
管理员
#include <bits/stdc++.h> using namespace std; int main() { int m; scanf("%d",&m); printf("%d",m);//不需要输出m值 if(m<=0||m>11){ printf("输入错误:\n"); return 1; } double sum=0.0; int n=1; while(sum<m) { sum+=1.0/n; n++;//注意这里,当找到满足sum>=m的n时,n还是会在这里+1,所以输出结果是n-1 } printf("满足不等式最小的n值为:/n");//转义符为\,'\n'回车。这里的输出可以不要,题目未做要求,包括下面的n= printf("n=%d");//printf("n=%d",n-1); return 0; }
本版积分规则 发表回复 回帖后跳转到最后一页
Archiver|手机版|小黑屋|DiscuzX
GMT+8, 2025-2-13 05:13 , Processed in 0.053358 second(s), 28 queries .
Powered by Discuz! X3.4
© 2001-2013 Comsenz Inc.. 技术支持 by 巅峰设计