首页 > 其他 > 详细

实验3

时间:2019-11-18 13:28:04      阅读:73      评论:0      收藏:0      [点我收藏+]
#include <stdio.h>
#include <stdlib.h>
int main() {
    int number, max, min, n;
    
    n=1;
    printf("输入第%d个数: ", n);
    scanf("%d", &number);
    max = number;
    min = number;
    
    while(n<5) {
        n++;
        printf("输入第%d个数: ", n);
        scanf("%d", &number);    

        if(number>max)
            max = number;
        else if(number<min)
            min = number;
    }
    
    printf("最大数为: %d\n", max);
    printf("最小数为: %d\n", min);
    
    system("pause");
    
    return 0;
} 

技术分享图片

#include <stdio.h>
int main()
{
    int count=0;
    int i=0;
    for(i=100;i<=200;i++)
    {
    int j=0;
    for(j=2;j<i;j++)
    {
    if(i%j==0)
    break; 
    }
    if(j==i)
    {
        count++;
        printf("%d\n",i);
    }
}
printf("\n");
printf("素数的个数为:%d\n",count);
return 0;
}

技术分享图片

#include <stdio.h>
int main(){
    long s,t,n,x;
    printf("enter a number:");
    scanf("%d",&s);
    t=s,n=1;
    while(t/=10) n*=10;
    while(s){
        if((x=s/n)&1)
        (t*=10)+=x;
        s%=n,n/=10; 
    } 
    printf("the new number is %d\n",t);
    return 0 ;
}

技术分享图片

 

实验3

原文:https://www.cnblogs.com/mario12138/p/11881300.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!