杭电oj 2719
?
Tips:本程序沒有什么難度,只要按照邏輯進行替換即可,需要注意的是,由于輸入串中含有空格符號,所以不能使用scanf("%s",ch);來讀取一串,可以使用gets()函數讀取一行字符。
1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 char ch[80]; 6 while(gets(ch))//不能使用sacnf("%s,ch),因為遇見空格就會結束讀入 7 { 8 if(*ch == '#') 9 { 10 return 0; 11 } 12 char temp[240]; 13 int j=0; 14 for(int i=0; i<strlen(ch);i++) 15 { 16 if(ch[i] == ' ') 17 { 18 temp[j++] = '%'; 19 temp[j++] = '2'; 20 temp[j++] = '0'; 21 }else if(ch[i] == '!') 22 { 23 temp[j++] = '%'; 24 temp[j++] = '2'; 25 temp[j++] = '1'; 26 }else if(ch[i] == '$') 27 { 28 temp[j++] = '%'; 29 temp[j++] = '2'; 30 temp[j++] = '4'; 31 }else if(ch[i] == '%') 32 { 33 temp[j++] = '%'; 34 temp[j++] = '2'; 35 temp[j++] = '5'; 36 }else if(ch[i] == '(') 37 { 38 temp[j++] = '%'; 39 temp[j++] = '2'; 40 temp[j++] = '8'; 41 }else if(ch[i] == ')') 42 { 43 temp[j++] = '%'; 44 temp[j++] = '2'; 45 temp[j++] = '9'; 46 }else if(ch[i] == '*') 47 { 48 temp[j++] = '%'; 49 temp[j++] = '2'; 50 temp[j++] = 'a'; 51 }else 52 { 53 temp[j++] = ch[i]; 54 } 55 56 } 57 58 int i=0; 59 while(i<j) 60 { 61 printf("%c",temp[i]); 62 i++; 63 } 64 65 printf("\n"); 66 } 67 return 0; 68 }?
轉載于:https://www.cnblogs.com/wujiyang/p/4534048.html
總結
- 上一篇: window服务器开站点(不通用)
- 下一篇: Android4大组件