zoukankan      html  css  js  c++  java
  • 实验三

    1.for循环

    2.while循环

    3.do while循环

    2水仙花数

    #include "stdafx.h" #include <stdio.h>

    int main(){

     int a,b,c,d,e;

     int s=0

    ;  for(a=100;a<1000;a=a+1)

    {   b=a/100;

      c=(a/10)%10;  

     d=a%10;  

     e=b*b*b+c*c*c+d*d*d;

      if(e==a){

      s++;   printf("水仙花数为%d\n",a);  

     }

     }

     printf("水仙花数的个数为%d\n",s);

     return 0;

    }

    3.0

    #include "stdafx.h" #include <stdio.h>

    int main()

    {

     int a,b,c,d,e;

     e=0;

     for(a=1;a<6;a++)

    {  

     for(b=1;b<6;b++)

    {  

      for(c=1;c<6;c++)

    {     if(a!=b&&b!=c&&a!=c)

    {      d=a*100+b*10+c;   

       printf("三位数为%d\n",d);  

         e++;  

       }

       }

      }

     }

     printf("三位数有%d位\n",e);  

      return 0;

    }

  • 相关阅读:
    Ceph
    linux五天光速入门
    shell编程
    Docker&K8S&持续集成与容器管理--系列教程
    openstack系列
    爬虫快速入门
    python奇闻杂技
    机器学习
    数据分析
    量化分析
  • 原文地址:https://www.cnblogs.com/P201821430026/p/10838647.html
Copyright © 2011-2022 走看看