#include<stdio.h>
#include<string.h>
int main(){
char str[999999];
char keyboard[] = "`1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./";
while(gets(str)){
for(int i = 0; i < strlen(str); i++){
if(str[i] == ' '){
printf(" ");
}
else{
for(int j = 0; j < strlen(keyboard); j++){
if(str[i] == keyboard[j]){
str[i] = keyboard[j - 2];
printf("%c", str[i]);
}
//printf("\n");
}
}
}
}
}
我試過不寫"printf("\n");",但無法把下行輸入的字串於下行輸出:也試過加上"printf("\n");",但只會印出一個字元,請問能如何修改?
#include
#include
int main(){
char str[999999];
char keyboard[] = "`1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./";
while(gets(str)){
for(int i = 0; i < strlen(str); i++){
if(str[i] == ' '){
printf(" ");
}
else{
for(int j = 0; j < strlen(keyboard); j++){
if(str[i] == keyboard[j]){
str[i] = keyboard[j - 2];
printf("%c", str[i]);
}
//printf("\n");
}
}
}
}
}
我試過不寫"printf("\n");",但無法把下行輸入的字串於下行輸出:也試過加上"printf("\n");",但只會印出一個字元,請問能如何修改?
printf("\n") 要放在for迴圈外面