用户:
孤言查看:20 回复:17 评论:20 创建时间:2021-02-13T16:34:25










孤言教程目录:
第7弹 循环(下):https://shequ.codemao.cn/community/363610
第6弹 循环(上)、作用域:https://shequ.codemao.cn/community/361喵2
第5弹 分支:https://shequ.codemao.cn/community/359246
第4弹 运算:https://shequ.codemao.cn/community/337749
第3弹 流输入/输出:https://shequ.codemao.cn/community/333986
第2弹 变量与常量:https://shequ.codemao.cn/community/333545
第1弹 C++入门:https://shequ.codemao.cn/community/333520
点赞0
评论
ParseYPasy请顺带介绍下:
std::string str = "ABC";
for(auto && i : str)
i++;
std::cout << str;
基于范围的for循环也是很重要的一种循环形式。
点赞0
评论
一颗柠檬lemon#include<iostream>
using namespace std;
int main(){
int i1,i2,i3,i4,v,n1,n2;
int num=0;
int a,b;
double t1,t2,t3,t4,choice[4],s1[4],s2[4][4],t;
for(;;){
cout<<"########################## ¶þÊ®Ëĵã ###################################\nÓÑÇéÌáʾ£ºA=1,J=11,Q=12,K=13\n";
cout<<"Çë¸ø³öÄã³éµ½µÄµÚÒ»ÅÆ£º";
cin>>choice[0];
cout<<"Çë¸ø³öÄã³éµ½µÄµÚ¶þÅÆ£º";
cin>>choice[1];
cout<<"Çë¸ø³öÄã³éµ½µÄµÚÈýÅÆ£º";
cin>>choice[2];
cout<<"Çë¸ø³öÄã³éµ½µÄµÚËÄÅÆ£º";
cin>>choice[3];
cout<<"########################## THINKING ###################################\n";
for(b=0;b<=2;b++)
for(a=3;a>=1+b;a--)if(choice[a]<choice[a-1]){
t=choice[a-1];
choice[a-1]=choice[a];
choice[a]=t;}
for(int j=0;j<4;j++)cout<<j+1<<". "<<choice[j]<<" ";
cout<<"\n";
for(i1=0;i1<4;i1++){
t1=choice[i1];
for(i2=0;i2<4;i2++){ if((i1-1)!=0 && t1==choice[i1-1])break;
if(i2!=i1){
t2=choice[i2];
s1[0]=t1+t2;
s1[1]=t1-t2;
s1[2]=t1*t2;
s1[3]=t1/t2;
for(i3=0;i3<4;i3++){
if(i3!=i1&&i3!=i2){
t3=choice[i3];
for(v=0;v<4;v++)
{s2[v][0]=s1[v]+t3;
s2[v][1]=s1[v]-t3;
s2[v][2]=s1[v]*t3;
s2[v][3]=s1[v]/t3;}
for(i4=0;i4<4;i4++){
if(i4!=i1&&i4!=i2&&i4!=i3){
t4=choice[i4];
for(n1=0;n1<4;n1++)for(n2=0;n2<4;n2++)
if(s2[n1][n2]+t4==24||s2[n1][n2]-t4==24||s2[n1][n2]*t4==24||s2[n1][n2]/t4==24){
cout<<"ÕÒµ½Ò»ÖÖ×éºÏ·½°¸£º\n(("<<t1;
if(s1[n1]==t1+t2)cout<<" + ";
if(s1[n1]==t1-t2)cout<<" - ";
if(s1[n1]==t1*t2)cout<<" * ";
if(s1[n1]==t1/t2)cout<<" / ";
if(n2==0)cout<<t2<<") + "<<t3;
if(n2==1)cout<<t2<<") - "<<t3;
if(n2==2)cout<<t2<<") * "<<t3;
if(n2==3)cout<<t2<<") / "<<t3;
if(s2[n1][n2]+t4==24)cout<<") + "<<t4<<" = 24 \n";
if(s2[n1][n2]-t4==24)cout<<") - "<<t4<<" = 24 \n";
if(s2[n1][n2]*t4==24)cout<<") * "<<t4<<" = 24 \n";
if(s2[n1][n2]/t4==24)cout<<") / "<<t4<<" = 24 \n";
num++;
}
}}}
}}}}
cout<<"×ܹ²ÓÐ"<<num<<"Öֽⷨ¡£\n";
if(num==0)cout<<"ÕâËÄÕÅÅÆÎÞ·¨¹¹³É24µã~~~\n";
num=0;
}
return 0;
}点赞0
评论
寂寞de奶酪#include <iostream>
using namespace std;
int main(){
long long num;
cin>>num;
bool flag=true;
if(num<2){
flag=false;
}
for(long long i=2;i*i<=num;i++){
if(num%i==0){
flag=false;
break;
}
}
if(flag)
cout<<"Yes";
else
cout<<"No";
return 0;
}点赞0
评论
#include<iostream>
using namespace std;
int main()
{
while(ture)//for(;;)也可以制造永久循环
{
cout<<1<<endl;
}
return 0;
}点赞0
评论
#include <iostream>
#include <random>
int main() {
// 创建一个随机数生成器
std::random_device rd; // 用于随机数种子
std::mt19937 gen(rd()); // 生成一个梅森旋转算法生成器
// 定义一个范围,例如[1, 100]
std::uniform_int_distribution<> distrib(1, 100);
// 生成并输出10个随机数
for (int n = 0; n < 10; ++n) {
std::cout << distrib(gen) << ' '; // 输出随机数
}
std::cout << std::endl;
return 0;
}点赞0
评论
氰草#include<cstdio>
#define FN(S) F operator S (const F& x) const
#define ull long long
#define v ((p+1)>>1)
#define p 1000000007
struct F
{
ull a,b;
F(ull a=0,ull b=0):a(a),b(b){}
FN(+){return{(a+x.a)%p,(b+x.b)%p};}
FN(-){return{(a-x.a+p)%p,(b-x.b+p)%p};}
FN(*){return{(a*x.a+5*b*x.b)%p,(a*x.b+x.a*b)%p};}
};
inline F P(F a,ull t)
{
F r = F(1,0);
while(t){if(t&1)r=r*a;a=a*a;t>>=1;}
return r;
}
int main()
{
ull n;
scanf("%lld",&n);
printf("%lld",(P(F(v,v),n)-P(F(v,v-1),n)).b);
return 0;
}
点赞0
评论