//
b761: 搶30 兩人輪流 疊積木,可放1~3個,疊第 N 個的 fat 、否則 egg
#include <iostream>
using namespace std;
int main()
{
// 程式敘述
n為 4倍則 egg
int
n;
while(cin>>n)
cout << (n%4==0?"egg":"fat") << endl;
return 0;
}
//d049.
中華民國萬歲! -- 板橋高中教學題
#include <iostream>
using namespace std;
int main( )
{
int
y;
while(cin >>y)
{
cout << y-1911<< endl;
}
return 0 ;
}
//d050.
妳那裡現在幾點了? -- 板橋高中教學題
#include <iostream>
using namespace std;
int main( )
{
int h;
while(cin>>h)
{
cout << (h+9)%24 << endl;
}
return 0 ;
}
//
d058. BASIC 的 SGN 函數 -- 板橋高中教學題
#include <iostream>
using namespace std;
int main( )
{
int
n;
while( cin>>n )
{
cout << (n>0)-(n<0) << endl;
}
return 0 ;
}
//
d060. 還要等多久啊? -- 板橋高中教學題
#include <iostream>
using namespace std;
int main( )
{
int
m;
while( cin >> m )
{
cout << (60-(m+35)%60)%60 << endl;
}
return 0 ;
}
//
d063. 0 與 1 -- 板橋高中教學題
#include <iostream>
using namespace std;
int main( )
{
int
k;
while(cin>>k)
{
cout<<1-k<<endl;
}
return 0 ;
}
//
d064. ㄑㄧˊ 數? -- 板橋高中教學題
#include <iostream>
using namespace std;
int main( )
{
int
i;
while (cin >>i)
{
cout << (i%2?"Odd":"Even" )<< endl;
}
return 0 ;
}
// d065. 三人行必有我師 -- 板橋高中教學題
#include <iostream>
using namespace std;
int main( )
{
int a,b,c;
while (cin >>a>>b>>c)
{
cout << (a>=b ? ((a>=c)?a:c) : ((b>=c)?b:c) ) <<
endl;
}
return 0 ;
}
// d066.
上學去吧! -- 板橋高中教學題 7:30含至17:00不含 為 At School
#include <iostream>
using namespace std;
int main( )
{
int
h,m;
while ( cin >> h >> m )
{
cout << ( (h==7&&m>=30 ||
h>7&&h<17)?"At":"Off") << "
School\n" ;
}
return 0 ;
}
// d067. 文文的求婚--續集 (1 行版) -- 板橋高中教學題
#include <iostream>
using namespace std;
int main( )
{
int
y;
cin >>y;
//
string s = (!(y%400)||(y%100)&&(!(y%4))) ?
"leap" : "normal" ;
// 或 if(y%400==0 ||
(y%100 && y%4==0) ) s="leap"; else s="normal";
// cout
<< "a " << s << " year\n" ;
cout << "a " << (
(!(y%400)||(y%100)&&(!(y%4))) ? "leap" : "normal" )
<< " year\n" ;
return 0 ;
}
//
d068. 該減肥了! -- 板橋高中教學題
#include <iostream>
using namespace std;
int main( )
{
int
w;
while (cin >>w)
{
cout << (w>50?w-1:w) << endl;
}
return 0 ;
}
//
d069. 文文的求婚--續集 (n 行版) -- 板橋高中教學題
#include <iostream>
using namespace std;
int main( )
{
int
n,y;
cin >> n;
while
(n--)
{
cin >> y;
cout << "a " << (
(!(y%400)||(y%100)&&(!(y%4))) ? "leap" : "normal" )
<< " year\n" ;
}
return 0 ;
}
//
d070. 文文的求婚--續集 (0 尾版) -- 板橋高中教學題
#include <iostream>
using namespace std;
int main( )
{
int
y;
while
( cin >> y , y )
{
//
或在迴圈內 if(y==0) break;
cout << "a " << (
(!(y%400)||(y%100)&&(!(y%4))) ? "leap" : "normal" )
<< " year\n" ;
}
return 0 ;
}
//
d071. 文文的求婚--續集 (EOF版) -- 板橋高中教學題
#include <iostream>
using namespace std;
int main( )
{
int
y;
while
( cin >> y )
{
cout << "a " << (
(!(y%400)||(y%100)&&(!(y%4))) ? "leap" : "normal" )
<< " year\n" ;
}
return 0 ;
}
//
d072. 文文的求婚--續集 (CASE版) -- 板橋高中教學題
#include <iostream>
using namespace std;
int main( )
{
int
y,n,i;
cin
>> n;
for(i=1;i<=n;i++)
{
cin >> y;
cout << "Case " << i << ": a "
<< ( (!(y%400)||(y%100)&&(!(y%4))) ? "leap" :
"normal" ) << " year\n" ;
}
return 0 ;
}
//
d073. 分組報告 -- 板橋高中教學題
#include <iostream>
using namespace std;
int main( )
{
int
n;
while
(cin >> n)
{
cout << (n+2)/3 << endl;
}
return 0 ;
}
//
d461. 班際籃球賽 -- 板橋高中教學題
#include <iostream>
using namespace std;
int main( )
{
int n;
while(cin>>n) // while 內只有一行可不加大括號
cout<<n-1<<endl;
return 0 ;
}
//
d483. hello, world -- Wikipedia
#include <iostream>
using namespace std;
int main()
{
cout <<"hello, world" <<endl ;
return 0;
}
//
d498. 我不說髒話 -- 板橋高中教學題
#include <iostream>
using namespace std;
int main( )
{
int
n;
while(cin>>n)
{
while(n--)
cout<<"I don't say swear words!"<<endl;
}
return 0 ;
}
//
d827. 買鉛筆 -- 板橋高中教學題
#include <iostream>
using namespace std;
int main( )
{
int
n;
while( cin>>n )
cout<<( (n/12)*50+(n%12)*5 )<<endl;
return 0 ;
}
0 意見:
張貼留言