1【程序设计】
功能:将tt数组中的小写字母都改为对应的大写字母,其它字符删除。
例如:a4 bdsk88*,结果:ABDSK
void TestFunc();
#include
#include
void fun(char tt[])
{/*********Begin**********/
int i,j=0;
for(i=0;tt[i];i++)
if(('a'<=tt[i])&&(tt[i]<='z'))
tt[j++]=tt[i]-32;
tt[j]=0;
/********** End **********/}
main()
{ char tt[81];
printf("\nPlease enter a string:");
gets(tt);
fun(tt);
printf("\nThe result string is:\n%s",tt);
TestFunc();}
void TestFunc()
{ ILE *IN,*OUT;
char s[100];
IN=fopen("in.dat","r");
if(IN==NULL)
{ printf("Read FILE Error");}
OUT=fopen("out.dat","w");
if(OUT==NULL)
{ printf("Write FILE Error");
fgets(s,100,IN);
fun(s);
fprintf(OUT,"%s",s);
fclose(IN);
fclose(OUT)}
2【程序设计】
功能:删除bb[]数组中所有值为y的元素,函数返回值为删除y后剩余数据的个数。数组元素中的值和y的值由函数通过键盘输入。
#include "stdio.h"
#include "conio.h"
#define M 20
int fun(int bb[],int n,int y)
{int i,k=0;