以下是程序設(shè)計導(dǎo)論中偽代碼的各個語言實現(xiàn)的代碼。
C
文件名:shishiqiushi1_1.c
#include<stdio.h>
int main(){
char str[20];
scanf("%s",str);
printf("%s",str);
return 0;
}
文件名:shishiqiushi1_2.c
#include<stdio.h>
int main(){
int n;
scanf("%d",&n);
char str[20];
for(int i = 0; i < n; i++){
scanf("%s",str);
printf("%s",str);
}
return 0;
}
C++
文件名:shishiqiushi1_1.cpp
#include<iostream>
using namespace std;
int main(){
char str[20];
cin>>str;
cout<<str<<endl;
}
文件名:shishiqiushi1_2.cpp
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
char str[20];
for(int i = 0; i < n; i++){
cin>>str;
cout<<str<<endl;
}
return 0;
}
Java
文件名:Shishiqiushi1_1.Java
import java.util.Scanner;
public class shishiqiushi1_1{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
String str = sc.next();
System.out.println(str);
}
}
文件名:Shishiqiushi1_2.Java
import java.util.Scanner;
public class shishiqiushi1_2{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int i = 0;i < n;i++){
String str = sc.next();
System.out.println(str);
}
}
}
Python
文件名:shishiqiushi1_1.py
str1 = input()
print(str1)
文件名:shishiqiushi1_2.py
n = int(input())
for i in range(n):
str1 = input()
print(str1)
通用額外問題
以下問題為選擇各個語言的人必須解決:
- 掌握當(dāng)不給定輸入用例的個數(shù)時囚痴,應(yīng)該怎樣編寫代碼接收輸入。
- 熟悉各個語言里的SCANF()和PRINT()即輸入輸出的函數(shù)的具體實現(xiàn)情況隙券。
- 了解里面出現(xiàn)的For循環(huán)結(jié)構(gòu)嗅绸。
- 了解基本數(shù)據(jù)結(jié)構(gòu)里面的數(shù)組麻裁。
語言專屬特性問題
以下問題為選擇各個語言分支的人選擇解決:
C
- 掌握include的作用。
- 掌握scanf()中"%s"的作用嗤锉,以及同類標(biāo)準(zhǔn)化輸入的處理渔欢。
- 掌握scnaf()中&n的作用。
- 掌握printf()中"%s"的作用瘟忱,以及這里跟scanf處的區(qū)別奥额。
- 了解C語言的程序塊的結(jié)構(gòu)的作用。
C++
- 掌握include的作用访诱。
- 掌握cin的作用垫挨,以及輸入過程的作用。
- 掌握cout的作用触菜,以及輸入過程的作用九榔。
- 了解C語言的程序塊的結(jié)構(gòu)的作用。
- 了解using namespace std的作用涡相,以及std相關(guān)內(nèi)容哲泊。
Java
- 掌握import的作用。
- 掌握Scanner的方法催蝗。
- 了解System.in與System.out切威。
- 掌握J(rèn)ava里類名與文件名的關(guān)系。
- 了解Java里程序塊的結(jié)構(gòu)的作用丙号。
Python
- 掌握input()的使用先朦。
- 了解Python里隱式聲明類型的過程缰冤。
- 掌握print()與了解格式化字符串format方法。
- 掌握int()類型轉(zhuǎn)換方法喳魏。
- 了解range()的作用棉浸。