2018年
1、从控制台输入字符串,将其中的小写字母转化为大写字母,并将结果写入文件中(✔)
int main(int argc, char *argv[]) {
char buff[100];
int i;
printf("enter a string: ");
//gets从控制台获取字符串,并将其送入buff缓冲
gets(buff);
for(i = 0;i < 100;i++)
{
if(buff[i] >= 'a' && buff[i] <= 'z' )
buff[i] = buff[i] + 'A' - 'a';
}
printf("%s\n",buff);
FILE *fp = NULL;
fp = fopen("result.txt","w+");
fputs(buff,fp);
fclose(fp);
}
2、判断从键盘中输入的数是否是对称数(✔)
//reverse
int reverse(int num)
{
int res = num;
int reverseInteger = 0;
int remainder;
while(res != 0)
{
remainder = res % 10;
reverseInteger = reverseInteger*10 + remainder;
res/=10;
}
return reverseInteger;
}