财政部关于ppp新要求:int maxline = 0;/* 文章的总行数 */ 为什么为0?
来源:百度文库 编辑:高校问答 时间:2024/10/04 17:52:48
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <ctype.h>
char xx[50][80] ;
int maxline = 0 ;/* 文章的总行数 */
int ReadDat(void) ;
void WriteDat(void) ;
void StrOL(void)
{int i,j,k,str1,l;char c;
for(i=0;i<maxline;i++) /*把各行中多余的标点符号去掉*/
for(j=0;j<strlen(xx[i]);j++)
{ c=xx[i][j];
if ((c>='A' && c<='Z') || (c>='a' && c<='z') || c==' '||(c>='0' && c<='9'));
else xx[i][j]=' ';
}
for(l=0;l<maxline;l++)
{ char ch[80]={0};
char pp[80]={0};
str1=strlen(xx[l]);
i=str1-1;
k=1;
while(1)
{while (((xx[l][i]>='a' && xx[l][i]<='z') || (xx[l][i]>='A' && xx[l][i]<='Z') || (xx[l][i]>='0' && xx[l][i]<='9')) && i>=0)/*处理字母和数字*/
{ for(j=k;j>=0;j--) /*从当前行的最后一个字符开始取字符,直到遇到空格*/
pp[j+1]=pp[j];
pp[0]=xx[l][i];
k++;i--;
}
strcat(ch,pp); /*把该单词存放到数组ch中*/
strcpy(pp, ""); /*清空数组pp*/
k=1;
if(i==-1)break; /*如果处理完了一行,则退出循环*/
while((xx[l][i]<'0'||(xx[l][i]>'9'&&xx[l][i]<'A') || xx[l][i]>'z') && i>=0) /*处理空格*/
{for(j=k;j>=0;j--)
pp[j+1]=pp[j];
pp[0]=xx[l][i];
k++;
i--;
}
strcat(ch,pp); /*把空格加到数组ch中*/
strcpy(pp,""); /*清空数组pp*/
k=0;
if(i==-1)break; /*如果处理完了一行,则退出循环*/
}
strcpy(xx[l],ch); /*把已处理的字符串仍按行重新存入字符串数组xx中*/
}
}
main()
{
clrscr() ;
if (ReadDat ())
{
printf("数据文件 IN2.DAT不能打开!\n\007") ;
return ;
}
StrOL() ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
char *p;
if((fp = fopen("IN2.DAT", "r")) == NULL) return 1 ;
while(fgets(xx[i], 80, fp) != NULL)
{
p = strchr(xx [i], '\n') ;
if(p) *p = 0 ;
i++ ;
}
maxline = i ;
fclose(fp) ;
return 0 ;
}
void WriteDat(void)
{
FILE*fp ;
int i ;
clrscr() ;
fp = fopen("OUT2.DAT", "w") ;
for(i = 0 ; i < maxline ; i++)
{
printf("%s\n", xx[i]) ;
fprintf(fp, "%s\n", xx[i]) ;
}
fclose(fp) ;
}
int maxline = 0;/* 文章的总行数 */ 为什么为0?
还有中间k是什么作用?
先谢了!!!!!!!!!
#include <string.h>
#include <conio.h>
#include <ctype.h>
char xx[50][80] ;
int maxline = 0 ;/* 文章的总行数 */
int ReadDat(void) ;
void WriteDat(void) ;
void StrOL(void)
{int i,j,k,str1,l;char c;
for(i=0;i<maxline;i++) /*把各行中多余的标点符号去掉*/
for(j=0;j<strlen(xx[i]);j++)
{ c=xx[i][j];
if ((c>='A' && c<='Z') || (c>='a' && c<='z') || c==' '||(c>='0' && c<='9'));
else xx[i][j]=' ';
}
for(l=0;l<maxline;l++)
{ char ch[80]={0};
char pp[80]={0};
str1=strlen(xx[l]);
i=str1-1;
k=1;
while(1)
{while (((xx[l][i]>='a' && xx[l][i]<='z') || (xx[l][i]>='A' && xx[l][i]<='Z') || (xx[l][i]>='0' && xx[l][i]<='9')) && i>=0)/*处理字母和数字*/
{ for(j=k;j>=0;j--) /*从当前行的最后一个字符开始取字符,直到遇到空格*/
pp[j+1]=pp[j];
pp[0]=xx[l][i];
k++;i--;
}
strcat(ch,pp); /*把该单词存放到数组ch中*/
strcpy(pp, ""); /*清空数组pp*/
k=1;
if(i==-1)break; /*如果处理完了一行,则退出循环*/
while((xx[l][i]<'0'||(xx[l][i]>'9'&&xx[l][i]<'A') || xx[l][i]>'z') && i>=0) /*处理空格*/
{for(j=k;j>=0;j--)
pp[j+1]=pp[j];
pp[0]=xx[l][i];
k++;
i--;
}
strcat(ch,pp); /*把空格加到数组ch中*/
strcpy(pp,""); /*清空数组pp*/
k=0;
if(i==-1)break; /*如果处理完了一行,则退出循环*/
}
strcpy(xx[l],ch); /*把已处理的字符串仍按行重新存入字符串数组xx中*/
}
}
main()
{
clrscr() ;
if (ReadDat ())
{
printf("数据文件 IN2.DAT不能打开!\n\007") ;
return ;
}
StrOL() ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
char *p;
if((fp = fopen("IN2.DAT", "r")) == NULL) return 1 ;
while(fgets(xx[i], 80, fp) != NULL)
{
p = strchr(xx [i], '\n') ;
if(p) *p = 0 ;
i++ ;
}
maxline = i ;
fclose(fp) ;
return 0 ;
}
void WriteDat(void)
{
FILE*fp ;
int i ;
clrscr() ;
fp = fopen("OUT2.DAT", "w") ;
for(i = 0 ; i < maxline ; i++)
{
printf("%s\n", xx[i]) ;
fprintf(fp, "%s\n", xx[i]) ;
}
fclose(fp) ;
}
int maxline = 0;/* 文章的总行数 */ 为什么为0?
还有中间k是什么作用?
先谢了!!!!!!!!!
0?初始化这个变量而已
int maxline = 0;/* 文章的总行数 */ 为什么为0?
int(-3.21)=
int a=2,b=3; float x=3.5,y=2.5; (float) (a+b)/2+(int)x%(int)y怎么算?
int f(int k,int m=0,double d=0.0); 则f(3,5,6.7)是它的合法调用,为什么?
void* vp = (void*)0xF1F2F3F4; int i = (int)vp;怎么消除它的编译告警
请问在进制中"Int a"代表什么意思?int a = 0 x 100F又是什么意思?指教```
unsigned int a=2;int b = -3;
程序int maxkline=0
a=2,b=3,x=3.5,y=2.5,求(float)(a+b)/2+(int)x/(int)y的值?
请问在进制中"Int a"代表什么意思?int a = 0 x 100F又是什么意思?望举例说明,越详细越好.谢谢!