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

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

#include <stdio.h>

int main(){

         int a=22;

         long int s=0;

         do{   

        s=s+a;

        a=a+20;

         }while (a<=1002);

printf("%d",s);

return 0;

 

}

 

 

 

#include<stdio.h>

int main()
{
 int a;
 int b=0;
 for(a = 22;a <= 1002;a=a+20)
 {b=b+a;}
 printf("%d\n",b);
 return 0;
}

#include<stdio.h>

int main()
{
 int s=22;
 int j=22;
 while(s<1000)
 {
  s=s+20;
  j=j+s;
 }
 printf("%d\n",j);
 return 0;
}

 

#include<stdio.h>

#include<math.h>

int main(){

 int n;

 int g;

 int s;

 int b;

 int j=0;  

for(n=100;n<1000;n++)

 {

 b=n/100;

 s=n/10%10;

 g=n%10;

 if(pow(g,3)+pow(s,3)+pow(b,3)==n)

 {  

printf("%d\n",n);  j=j+1;  }

 }

 printf("一共有%d个水仙花数\n",j);  

 return 0;

  }

 

#include <stdio.h>

#include <math.h>

int main(){

         int a,b,c,d,e;

         int sum;

         sum=0;

         for(a=1;a<=5;a++){

                   d=a*100;

                   for(b=1;b<=5;b++){

                            e=b*10;

                            for(c=1;c<=5;c++){

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

                                               printf("%d\n",d+e+c);

                                     sum=sum+1;

                                     }

                            }

                   }

         }

         printf("%d\n",sum); 

return 0;

}

 

转载于:https://www.cnblogs.com/p201821440003/p/10819658.html

你可能感兴趣的文章
设计中的道理_6
查看>>
MFC——AfxParseURL用法
查看>>
Cocos2d-x3.2 Sprite精灵类的创建与设置
查看>>
Starting MySQL.Manager of pid-file quit without updating file.[FAILED]
查看>>
深入浅出PostgreSQL B-Tree索引结构
查看>>
PostgreSQL 如何高效解决 按任意字段分词检索的问题 - case 1
查看>>
玩转PS路径,轻松画logo!
查看>>
浅析 JavaScript 中的闭包(Closures)
查看>>
python 之 PEP8 风格
查看>>
Python Pandas concat 的使用
查看>>
RHEL 网络的简单配置
查看>>
新机开源经历
查看>>
(Mac)VMware Fusion 安装centos ,mac访问不了centos里的web服务器解决方案
查看>>
GuozhongCrawler系列教程 (4) StartContext详解
查看>>
shell脚本案例
查看>>
Web语义化
查看>>
[case分享]Exchange 2013 IMAP问题解决历程
查看>>
nginx安装
查看>>
如何开启MySQL的远程帐号
查看>>
Linux下安装Oracle10g详细教程
查看>>