引用 | 編輯
bing80329
2009-12-23 23:58 |
樓主
▼ |
||
x0
大一的作業要求我們寫回文的程式題目 : 用C寫一個程式 , 判斷出輸入的字元(a,b,c...)是否為回文(abbba , aabaa ...) 使用程式: Microsoft Visual C++ 6.0 以下是我想到的 , 但是只能判斷4或5字元長度 , 請不吝指教 p.s. 希望可以提供我無限制字元長度的 , 感恩 #include <stdio.h> char a(char q[] , int w);char s(char e[] , int r); int main () { int z ; printf("size (請輸入4或是5) :\n") .. 訪客只能看到部份內容,免費 加入會員 x0
|
引用 | 編輯
su5gsm
2010-11-10 00:06 |
2樓
▲ ▼ |
#include <stdio.h>
#include <stdlib.h> int main(void) { int n,s=0,t; printf("input:n \n"); scanf("%d",&n); for (t=n;t>0;t=((t-(t%10))/10)) s=s*10+(t%10); // t>0 if (s==n) printf("%d is palindrome\n",n); else printf("%d is not palindrome\n",n); system("pause"); return 0 ; } x0 |
引用 | 編輯
s90304a123
2010-11-18 12:48 |
3樓
▲ ▼ |
不能用陣列的回文寫法就截然不同了
老師說現在不能用陣列 搞得我頭很疼.... x0 |