#include<stdio.h>
int main() {
// 输入非负整数
int m, n;
scanf("%d %d", &m, &n); // 声明和
int s=; // 求m到n(包括m和n)之间的所有奇数的和
// 遍历判断奇偶性 再加和
for(int i=m; i<=n; i++) {
if(i%!=) {
s+=i;
}
}
printf("%d\n", s);
return ;
}
/*
pkuic_6171.c
计算概论(A)/基础编程练习1(8题)/7:奇数求和
http://pkuic.openjudge.cn/base1/7/
7:奇数求和
查看 提交 统计 提问
总时间限制: 1000ms 内存限制: 65536kB
描述
计算非负整数 m 到 n(包括m 和 n )之间的所有奇数的和,其中,m 不大于 n,且n 不大于300。例如 m=3, n=12, 其和则为:3+5+7+9+11=35。
输入
两个数 m 和 n,两个数以一个空格分开,其中 0 <= m <= n <= 300 。
输出
输出一行,包含一个整数,表示m 到 n(包括m 和 n )之间的所有奇数的和
样例输入
7 15
样例输出
55
*/

计算概论(A)/基础编程练习1(8题)/7:奇数求和的更多相关文章

  1. 计算概论(A)/基础编程练习2(8题)/8:1的个数

    #include<stdio.h> int main() { ; // 存储测试数据的二进制形式中1的个数 int bian[N]; // 输入十进制整数N 表示N行测试数据 scanf( ...

  2. 计算概论(A)/基础编程练习2(8题)/7:整数的个数

    #include<stdio.h> int main() { ] = {}; // 输入k个正整数 scanf("%d",&k); // 循环读入和进行算术 w ...

  3. 计算概论(A)/基础编程练习2(8题)/6:数组逆序重放

    #include<stdio.h> int main() { // 输入n个整数 ; scanf("%d", &n); // 循环读入元素 while(scan ...

  4. 计算概论(A)/基础编程练习2(8题)/5:点和正方形的关系

    #include<stdio.h> #include<math.h> int main() { // 输入坐标 float x, y; while(scanf("%f ...

  5. 计算概论(A)/基础编程练习1(8题)/2:苹果和虫子

    #include<stdio.h> #include<math.h> int main() { /* n个苹果 每x小时能吃掉一个苹果 经过y小时 */ float n, x, ...

  6. 计算概论(A)/基础编程练习1(8题)/1:大象喝水

    #include<stdio.h> int main() { ; // n < 100 scanf("%d", &n); // 循环遍历判断 再进行平方和 ...

  7. 计算概论(A)/基础编程练习2(8题)/4:骑车与走路

    #include<stdio.h> int main() { // 待处理的数据数量n ; scanf("%d", &n); float meters[n]; ...

  8. 计算概论(A)/基础编程练习2(8题)/3:计算三角形面积

    #include<stdio.h> #include<math.h> int main() { // 声明三角形的三个顶点坐标和面积 float x1, y1, x2, y2, ...

  9. 计算概论(A)/基础编程练习2(8题)/2:计算书费

    #include<stdio.h> int main() { // 声明与初始化 ; // k组测试数据的总费用 double s[k]; // 单价表 double price[]= { ...

随机推荐

  1. python-django开发学习笔记四

    先插入一条广告,博主新开了一家淘宝店,经营自己纯手工做的发饰,新店开业,只为信誉!需要的亲们可以光顾一下!谢谢大家的支持!店名: 小鱼尼莫手工饰品店经营: 发饰.头花.发夹.耳环等(手工制作)网店: ...

  2. react封装简单的浏览器顶部加载进度条全局组件

    在项目中经常会有在请求前后加loading或者加加载进度条,一般这些组件都会抽离出来作为全局组件 进度条的插件貌似都不是很符合自己项目中的需求,于是.. 参考nprogress样式,自己在项目中封装组 ...

  3. ArcEngine TextElement 定位点的问题

    做ArcGIS Add-In开发,需要在ArcMap中数据视图的左上角加一个上标,如果上标与数据中的地名图层重合,则放在右上角. 上标通过ITextElement,IElement,ITextSymb ...

  4. Flask 学习篇二:学习Flask过程中的记录

    Flask学习笔记: GitHub上面的Flask实践项目 https://github.com/SilentCC/FlaskWeb 1.Application and Request Context ...

  5. POJ1860 Currency Exchange【最短路-判断环】

    Several currency exchange points are working in our city. Let us suppose that each point specializes ...

  6. 0001python中特殊的for迭代zip函数

    >>> a = [1,2,3,4,5] >>> b = [9,8,7,6,5] >>> length = len(a) if len(a)< ...

  7. hadoop第一部分-安装、测试

    一.hadoop安装(本地模式及伪分布式安装) hadoop历史版本下载网站:http://archive.apache.org/dist/运行模式:    本地模式    yarn模式 hadoop ...

  8. 3322.org

    3322.org — Krebs on Security https://krebsonsecurity.com/tag/3322-org/

  9. a loosely strongly typed language

    JavaScript: The Definitive Guide, Sixth Edition by David Flanagan As explained above, the following ...

  10. IP报文

      位字段的值设置为二进制的0100表示IP版本4(IPv4).设置为0110表示IP版本6(IPv6)   位,它表示32位字长的IP报头长度,设计报头长度的原因是数据包可选字段大小会发生变化.IP ...