菜鸟求C++文件程序(个人想的,认为比较有挑战性,有兴趣的进来)

来源:百度知道 编辑:UC知道 时间:2024/05/18 05:23:43
写一个文件程序,给一个文本文件的各行编号,事先统计号行数(为了判断是10行内还是10行外)并确定相应的域,并在此域中右对齐,在行号后加一个冒号,再添加一个空格,最后附上原来的文本(忽略原来文本的开头位置)。新的文本要求每一行的长度在60个字符内,在保证每行单词的完整性的前提下输出文本。将新文本输入到另一文件中。
In recent years crisis in welfare states has been high on the political scheme both in the Scandinavian countries and elsewhere.
The crisis consists of many individual elements and is partly due to the fact that the present welfare arrangements originated and developed in the 1960s and 1970s at a time of high economic growth and low unemployment.
It has never been the intention either with unemployment, sickness benefits or with cash benefits that so many people should receive them or that they should receive them for so long as has been the case in recent years.
The financing of the welfare state has thus become a problem, and as it has not been politically possible to increase taxes, which are already very high.The question is therefore whether the national compromise can be maintained in the future.

ACM题目

#include<stdio.h>
main()
{FILE *fp,*fp1;
int cap=0, i=1;
char mid,filename[10];
printf("Input the filename like *.txt!\n");
scanf("%s",filename);
if((fp=fopen(filename,"r"))==NULL)
{printf("Can not open the file!\n");
exit (0);
}
if((fp1=fopen("stdout.txt","w+"))==NULL)
{printf("Can not open the file!\n");
exit (0);
}
while(!feof(fp))
{
mid=fgetc(fp);
if(mid=='\n') cap++;
}
fclose(fp);
if((fp=fopen(filename,"r"))==NULL)
{printf("Can not open the file!\n");
exit (0);
}
fprintf(fp1,"%d ",i++);
while(!feof(fp))
{
if(fputc(fgetc(fp),fp1)=='\n')
fprintf(fp1,"%d ",i++);
}
printf("cap=%d \n",