close

原文

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1724

感謝Lucky 貓大大翻譯

https://zerojudge.tw/ShowProblem?problemid=c022

 

C++

#include <iostream>
using namespace std;

int main()
{
	int j,t,a,b;
	cin>>t;//輸入測資數量 
	
	for(int j=1;j<=t;j++)//計算case幾 
	{
		int ans=0;
		cin>>a>>b;//輸入範圍 
		
		for(int i=a;i<=b;i++)//奇數相加 
		{
			if(i%2==1)
			{
				ans=ans+i;
			}
		}
		
		cout<<"Case "<<j<<": "<<ans<<endl;//輸出 
	}
}
 
arrow
arrow
    文章標籤
    UVa一星題
    全站熱搜
    創作者介紹
    創作者 豪CO 的頭像
    豪CO

    程式道路,必為豐富

    豪CO 發表在 痞客邦 留言(0) 人氣()