博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
实验1
阅读量:7124 次
发布时间:2019-06-28

本文共 1282 字,大约阅读时间需要 4 分钟。

1

#include<iostream>

using namespace std;
int main(){
char n;
 while(1)
 {
 cout<<"Menu:A(dd) D(elete) S(ort) Q(uit),Select one"<<endl;
 cin>>n;
 if(n=='A')
 cout<<"数据已经增加"<<endl;
 
 else if(n=='D')
 cout<<"数据已经删除"<<endl;
 
 else if(n=='S')
 cout<<"数据已经排序"<<endl;
 
 else if(n=='Q')
 break;
 
 else
 cout<<"wrong selection"<<endl;
}
return 0;
}

 

 

 

2

#include<iostream>

using namespace std;
int main(){
 int n=2;
 for(n=2;n<=100;n++)
{
 int m=0;
 for(m=2;m<=n;m++)
 {
  if(n%m==0)
  {
  break;
  }
 }
 if(n==m)
 {
  cout<<n<<endl;
 }
}
return 0;
}

 

 

#include<iostream>

using namespace std;
int main()
{
    int m=2,n=1;
    cout<<m<<"  ";
    do { int i;
        for(i=2;i<m;i++)
        {
            if(m%i==0)
            {
                break;
            }
            else if(m%i!=0&&i==m-1)
            {
                if(n%5==0)
                {
                    cout<<endl;
                }
                cout<<m<<"  ";
                n++;
            }
        }
       m++;
    }

while(m<=100);

   return 0;
}

 

 

 

#include<iostream>

using namespace std;
int main(){
cout<<"几种颜色:";
int tnumber=0, number=0, i=0, s=0, x=0, k=0;
cin>>tnumber;
cout<<"几种颜色:";
cin>>number;
int sm=tnumber;
int st=number;
while(st>1){
sm=sm*(tnumber-1);
tnumber--;
st--;
}
int xm=1;
for(i=1;i<number;i++){
xm=xm*(i+1);
}
k=sm/xm;
cout<<"有"<<k<<"种取法!";
}

 

 

 

 

#include<iostream.h>

void main()
{
inti,j,n,m;
i=2;
do
{
m=1;
n=i/2;
j=2;
do
{
if(i%j==0)
{
m=0;
break;
}
j++;
}
while(j<=n);
if(m)
cout<<i<<" ";
i++;
}
while(i<101);
}

转载于:https://www.cnblogs.com/hi-ypy/p/10562366.html

你可能感兴趣的文章
Nginx中的正则表达式
查看>>
spring boot 传递 List参数
查看>>
passwd命令
查看>>
详解javascript原型
查看>>
我的友情链接
查看>>
supervisord进程管理
查看>>
BT5安装Orace Java JDK
查看>>
Mysql数据库优化技术
查看>>
Oracle的优化器
查看>>
Spring Cloud 学习笔记
查看>>
nf_conntrack的一些测试
查看>>
KeyMob:移动应用广告的管理者
查看>>
jsp分页代码
查看>>
Java(Android)线程池
查看>>
羊驼 CMS 实现 .html 结尾的 URL 格式
查看>>
回答ccflow工作流程引擎的一个朋友的常见问题
查看>>
nagios:CHECK_NRPE: Error - Could not complete SSL handshake.
查看>>
Spring MVC整合Velocity
查看>>
使用 GUID 值来作为数据库行标识讲解
查看>>
find命令详解
查看>>