{printf("error1");
exit(-1);
}fp2 = fopen("b.txt","w");
if(fp2 == NULL)
{printf("error2");
exit(-1);
}int i = 0;
int j = 0;while(fscanf(fp1,"%d",&a[i]) != EOF)
{
i++;
j++;
if(i >= MAX)
{
MAX = 2 * MAX;
b = (int*)realloc(a,MAX * sizeof(int));
if(b == NULL)
{
printf("error3");
exit(-1);
}
a = b;
}
}for(;--j >= 0;)
fprintf(fp2,"%d/n",a[j]);fclose(fp1);
fclose(fp2);return 0;
}第二题.
#include <stdio.h>int main(void)
{
unsigned long int i,j,k;printf("please input the number/n");
scanf("%d",&i);
if( i % 2 == 0)
j = i / 2;
else
j = i / 2 + 1;printf("The result is /n");
for(k = 0; k < j; k++)
printf("%d = %d + %d/n",i,k,i - k);
return 0;
}#include <stdio.h>
void main()
{
unsigned long int a,i=1;
scanf("%d",&a);
if(a%2==0)
{
for(i=1;i<a/2;i++)
printf("%d",a,a-i);
}
else
for(i=1;i<=a/2;i++)
printf(" %d, %d",i,a-i);
}兄弟,这样的题目若是做不出来实在是有些不应该, 给你一个递规反向输出字符串的例子,可谓是反序的经典例程.void inverse(char *p)
{
if( *p = = '/0' )
return;
inverse( p+1 );
printf( "%c", *p );
}int main(int argc, char *argv[])
{
inverse("abc/0");return 0;
}借签了楼上的“递规反向输出”
#include <stdio.h>
void test(FILE *fread, FILE *fwrite)
{
char buf[1024] = {0};
if (!fgets(buf, sizeof(buf), fread))
return;
test( fread, fwrite );
fputs(buf, fwrite);
}
int main(int argc, char *argv[])
{
FILE *fr = NULL;
FILE *fw = NULL;
fr = fopen("data", "rb");
fw = fopen("dataout", "wb");
test(fr, fw);
fclose(fr);
fclose(fw);
return 0;
}在对齐为4的情况下
struct BBB
{
long num;
char *name;
short int data;
char ha;
short ba[5];
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-36439-22.html
去投资损失的更多
航速18节以上
002515
犯我华夏者