首页 > 其他分享 >4.17打卡

4.17打卡

时间:2023-04-17 16:00:23浏览次数:34  
标签:std include cout 4.17 int namespace 打卡 main

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
    cout<<2<<endl;
    int i,j,k,flag;
    i=3;
    while(i<=100)
    {
        j=2;
        k=sqrt(i);
        flag=1;
        while(j<=k)
        {
            if(i%j==0)
            {
                flag=0;
                break;
            }
            j++;
        }
        if(flag)
        cout<<i<<endl;
        i++;
    }
    return 0;
}
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
    cout<<2<<endl<<3<<endl;
    int i,j,k,flag;
    for(i=2;i<=100;i++)
    {
        k=sqrt(i);
        for(j=2;j<=k;j++)
        {
            if(i%j==0)
            {
                flag=0;
                break;
            }
            flag=1;
        }
        if(flag)
        {
            cout<<i<<endl;
        }
    }
    return 0;
}
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
    cout<<2<<endl;
    int i,j,k,flag;
    i=3;
    do
    {
        flag=1;
        k=sqrt(i);
        j=2;
        do
        {
            if(i%j==0)
            {
                flag=0;
                break;
            }
            j++;
        }while(j<=k);
        if(flag)
        cout<<i<<endl;
        i++;
    }while(i<=100);
    return 0;
}

 

标签:std,include,cout,4.17,int,namespace,打卡,main
From: https://www.cnblogs.com/Sunyiran/p/17323509.html

相关文章

  • 4.17 离散化习题
    不理解啊不理解,找一堆和离散化没什么关系,中间最多sort一下的题就叫离散化练习题,打着离散化的牌子实则是一堆数据结构,意义何在?不懂啊不懂。今天只贴一道我比较喜欢的题,也是感觉唯一一道可做题。ACWing 2014.岛  传送门思路非常的简单(但其实还是看了题解....)。考虑枚举怎么......
  • 建民の每日打卡6
    一、问题描述 二、流程设计1.输入方程系数abcd2.将方程根x设为1.53.建立循环,将x赋值给x0,并按公式求出新的x。实现迭代4.当迭代满足条件后输出x值三、流程图设计 四、代码实现#include<iostream>#include<cmath>usingnamespacestd;intmain(){ floata,b,c,d,x,x0,......
  • 打卡第五天
    输入一个0~6的整数,转换成对应的星期输出一、1.定义一个变量day,用于存储输入值2.用switch语句将数字尽享转换并输出二、三、#include<iostream>usingnamespacestd;intmain(){ intday; cout<<"输入数字:"; cin>>day; switch(day) { case0: cout<<"Sunday"<<endl; ......
  • leetcode_打卡5
    leetcode_打卡5题目:345.反转字符串中的元音字母思路:双指针classSolution{publicStringreverseVowels(Strings){intn=s.length();char[]arr=s.toCharArray();inti=0;intj=n-1;while(i<j){while(i<n&&!yua......
  • 2023.4.16编程一小时打卡
    一、问题描述:线性代数里面我们学习过n维向量,请用类vector_N来封装n维整型向量,成员如下;私有数据成员: 向量维数n,int型指针p,int型公有函数成员:无参默认构造函数,在该函数中,将n置0,将p置null;重载输入输出运算符,输入运算符,先指定向量维数,若输入为非正整数,则提示错误信息,“Error......
  • c++训练打卡(8)
    冒泡排序流程图:伪代码:源代码:#include<stdio.h>intmain(){ intN,i,j,Max; inta[100]; printf("请输入要比较的数据的个数:"); scanf("%d",&N); printf("请输入所要比较的数据:"); for(i=0;i<N;i++){ scanf("%d",&a[i]); } for(i=0;i<N;i......
  • 每日打卡-5.2
    一.问题描述小A是某工地的计算工程师。工地现有n根钢管,第i根钢管的长度为ai。现在想用这n根钢管来做一个支撑用的柱子。我么可以切割这些钢管成为更短的钢管,但是不能缝合两根钢管。为了安全起见,柱子必须用至少k根长度相同的钢管加上混凝土制成,并且要求钢管长度必须为......
  • 每日打卡
    //#include<iostream>//usingnamespacestd;//intmain()//{// longlongintA,B,C;intD;// cin>>A>>B>>D;// C=A+B;// intn=0;// longlongm=C;// while(m!=0)// {// n++;// m/=D;// }// int*a=newint[n];// for......
  • 每日打卡-5.1
    一.问题描述  小A所在的学校又迎来了一年一度的开花活动,有n名学生被评为文学优秀奖,m名学生被评为体育优秀奖。现已知两个奖项获奖同学的编号,每个同学都有唯一的编号。只有同时被评为文学优秀奖和体育优秀奖的学生才能开花,小A想知道开花的名单,请你帮他统计一下。注:1<=n,m<=1e......
  • 天天打卡一小时——3
    一.问题描述输入一个0~6的数字,转化成数字输出二.设计思路1.输入0~6中任意一个数字2.需要运用多重分支结构3.选用switch语句三.程序流程图画不出来四.代码实现#include<iostream>usingnamespacestd;intmain(){intday;cin>>day;switch(day){case0:c......