uva - 10783 - Odd Sum 解题报告
原题链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1724
题目大意:给出一个范围a到b,求出a与b之间所有奇数的和
1 #include<stdio.h> 2 int main(){ 3 int n,a,b,i,t,s,k=0; 4 scanf("%d",&n); 5 while(n--){ 6 scanf("%d%d",&a,&b); 7 s=0; 8 for(i=a;i<=b;i++){ 9 t=i; 10 if(t%2!=0) s+=t;} 11 k++; 12 printf("Case %d: %d\n",k,s);} 13 }