在dev-c++都ok但是傳上去就不行
以下是我的程式碼
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
char a[130];
char b[130];
int c[200]={0},i,n;
gets(a);
n=strlen(a);
for(i=0 ; i<n ; i++)
{
c[i]=a[i]-7;
}
for(i=0 ; i<n ; i++)
{
b[i]=c[i];
}
puts(b);
//system("pause");
return 0;
}
在dev-c++都ok但是傳上去就不行
有幫你修改過程式碼
#include <stdio.h> // 中間的 #include <stdlib.h> 拿掉因為沒有用到 system("pause")
#include <string.h>
int main() {
char a[130]; // b[130] 拿掉是因為等等直接輸出就可以了
int i, n; // c[130] 也不需要
while( scanf("%s", &a ) != EOF ) { // 由於有多組測資所以要用 while 迴圈包起來
n=strlen(a);
for( i = 0 ; i < n ; i++ )
printf("%c", a[i]-7 ); // 如同上面所講 ascii 編碼直接減 7 就好
printf("\n"); // 換行
}
return 0;
}