程式:字串加密0->9,1->8,...
這錯誤我不知道怎麼改
要怎樣把不知道有幾組的數字放到陣列阿
我想改成數字的陣列 卻不知道怎改
#include
int reverse(int s1[],int s2[]);
void main()
{
int s1[1024],s2[1024];
printf("plz enter string\n");
if(getchar()>=0&&getchar()<=9)
scanf("%d",s1);
reverse(s1,s2);
printf("%d\n",s2);
}
int reverse(int s1[],int s2[])
{
int i=0,n2=0,n3;
while(s1[i]!='\0')
i++;
for(n2;n2
n3=9-s1[n2];
s2[n2]+=n3;
}
return 0;
}
麻煩一下~
2007-01-07 21:46:47 · 1 個解答 · 發問者 SHO 1 in 電腦與網際網路 ➔ 程式設計
http://tw.knowledge.yahoo.com/question/question?qid=1607010801307
也請你順便看一下這一題
謝謝
2007-01-08 06:13:45 · update #1
#include
void reverse(char input[],char output[]);
void main()
{
char input[1024],output[1024];
printf("plz enter string\n");
scanf("%s",input);
reverse(input,output);
printf("%s\n",output);
}
2007-01-09 11:11:51 · update #2
void reverse(char input[],char output[])
{
int len=0,n2;
while(input[len]!='\0')
len ;
n2=len-1;
for(int n=0;n
output[n]=input[n2];
n ;
n2--;
}
output[n]='\0';
}
貼正解方便以後大家使用
2007-01-09 11:12:17 · update #3
看看是不是你所要
#include
int reverse(char s1[],char s2[]);
void main()
{
char s1[1024],s2[1024];
int i, n;
printf("How many sets of integer : ");
scanf("%d", &n);
for (i = 0; i < n; i++)
{
printf("\nPlz enter set %d number : ", i+1);
scanf("%s", s1);
reverse(s1, s2);
printf("Set %d new number : %s \n", i+1, s2);
}
}
int reverse(char s1[],char s2[])
{
int i=0,n2;
while(s1[i] != 0)
i++;
for(n2=0;n2
{
s2[n2]=(char) ('9'-s1[n2]+ '0');
}
s2[i]=0;
return 0;
}
如果有問題, 請來函討論. 不然, 我可能會錯失你再補充的疑點.
2007-01-08 01:33:49 · answer #1 · answered by JJ 7 · 0⤊ 0⤋