#include <stdioh>
#include <stringh>
#define N 1//这里的1可以改,改成10同时可以玩10个串串
void printfmm(char s,int len){
if(len==0){printf("%c\n",s[len-1]);return;}
else {printf("%c",s[len-1]);printfmm(s,len-1);}
}
void main() {
char str[N][30],t;
int i,s[52]={0},j;
printf("上串串:");
for(i=0;i<N;i++)
gets(str[i]);
for(i=0;i<N;i++)
printfmm(str[i],strlen(str[i]));
}
#include <stdioh>#include <stdlibh>
#define CNTL_Z '\032'
#define SLEN 50
int main(void)
{
char file[SLEN];
char ch;
FILE fp;
long int count,last;
puts("Enter the name of the file to be processed:");
gets(file);
if((fp=fopen(file,"rb"))==NULL)
{
printf("Can't open file");
exit(1);
}
fseek(fp,0L,SEEK_END);
last=ftell(fp);
for(count=1L;count<=last;count++)
{
fseek(fp,-count,SEEK_END);
ch=getc(fp);
if(ch!=CNTL_Z&&ch!='\r')
{
putchar(ch);
}
putchar('\n');
}
fclose(fp);
return 0;
}思路:要想输出一个整数n的倒序,则先输出个位、十位、百位……,个位可以通过n%10得到,十位可以通过n/10%10得到,百位可以通过n%100%10得到……,所以可以通过先取余输出再除以10直到该数等于0为止。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)