程式設計可以改變您的未來(Programming can change your future)。
雲林SONG 全名為雲林軟體工程(SOftware eNGineering),目標致力於軟體人才的培養並推廣開源軟體落實於資訊教育。程式設計的觀念是軟體產品的基礎,程式碼就像沙子一樣,要紮實,所建立出來的高塔才會穩固。本站也提供資訊教育相關的教學資源。
YunlinSONG stands for Yunlin SOftware eNGineering, offering tutorial for computer programming and promoting open-source software.
Teaching resources in information technology education are provided here.
#include<cstdio>#include<iostream>usingnamespacestd;
voidprtPattern(int index, int right, int left, char *pattern){
if(index == right && left == index)
{
puts(pattern - 2 * index);
}
if( right < index )
{
*pattern = '(';
prtPattern(index, right + 1, left, pattern + 1);
}
if( left < right)
{
*pattern = ')';
prtPattern(index, right, left + 1, pattern + 1);
}
}
intmain(){
int n;
while(scanf("%d", &n) != EOF)
{
char str[32] = {'\0'};
prtPattern(n, 0, 0, str);
}
return0;
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h>intmain(){
char *msg[] = {"普通", "吉", "大吉"};
int m;
while(scanf("%d", &m) != EOF) {
int d;
scanf("%d", &d);
m = (m*2+d) % 3;
printf("%s\n", msg[m]);
}
return0;
}
C++程式碼:
#include<iostream>usingnamespacestd;
intmain(){
char *msg[] = {"普通", "吉", "大吉"};
short m;
while(cin >> m){
short d;
cin >> d;
m = (m*2+d) % 3;
cout << msg[m] << endl;
}
return0;
}
Python程式碼:
import sys
msg = ["普通", "吉", "大吉"]
for line in sys.stdin:
[m, d] = line.split()
m = int(m)
d = int(d)
m = (m*2+d) % 3
print(msg[m])
Java程式碼:
import java.util.Scanner;
publicclassJAVA{
publicstaticvoidmain(String[] args){
Scanner cin = new Scanner(System.in);
String msg[] = {"普通", "吉", "大吉"};
int m;
while (cin.hasNext()) {
m = cin.nextInt();
int d;
d = cin.nextInt();
m = (m*2+d) % 3;
System.out.println(msg[m]);
}
}
}
#include<cmath>#include<cstdio>usingnamespacestd;
intmain(void){
int num = 0;
int n = 0;
long result = 1;
while(scanf("%d", &num) != EOF)
{
for(int i = 1; i <= num; i++)
{
result = 1;
scanf("%d", &n);
while(n / 10 > 0)
{
int r = n % 10;
result *= r;
n = n / 10;
}
result *= n;
printf("%ld\n", result);
}
}
return0;
}
#include<iostream>/* run this program using the console pauser or add your own getch, system("pause") or input loop */usingnamespacestd;
intmain(int argc, char** argv){
string s = "";
while(cin >> s)
{
char c = s[0];
for(int i = 1; i < s.size(); i++) {
int code = c - s[i];
if(code < 0)
code = -code;
cout << code;
c = s[i];
}
cout << endl;
}
return0;
}