鱼C论坛

 找回密码
 立即注册
查看: 2687|回复: 0

C6改大写输出

[复制链接]
发表于 2022-5-12 15:45:50 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 我爱橙 于 2022-5-12 16:09 编辑

读入一行英文文本将其中每个单词的最后一个字母改成大写,然后输出此文本行(这里的单词是指由空格隔开的字符串)
例如:若输入"I am a student."
则应输出"I aM A studenT."

#include"conio.h"
#include"stdio.h"
#include"ctype.h"
#include"string.h"

up1st(char *p)
{
    
/**************FOUND********/
    integer k=0;
    for(;*p;p++)
    if(k)
    {
      /**************FOUND********/
      if(*p='')
      {
              k=0;
              /**************FOUND********/
        *(p-1)=toupper(*(p-1);
          }
        }
    else if(*p!='')k=1;
       *(p-1)=toupper(*(p-1));
}

main()
{
        char chrstr[81];
        clrscr();
        printf("\nPlease enter a string:");
        gets(chrstr);
        printf("\n\nBefore changing:\n%s",chrstr);
    up1st(chrstr);
    printf("\nAfter changing:\n%s",chrstr);
}

15        13         if(*p='  ')                         [Error] empty character constant
22        17     else if(*p!='')k=1;         [Error] empty character constant
10        5        [Error] 'integer' was not declared in this scope
12        8        [Error] 'k' was not declared in this scope
29        9        [Error] 'clrscr' was not declared in this scope


correct:
1.int k=0;         
2. if(*p=='  ')
3.*(p-1)=toupper(*(p-1));                                     √  



改正错误后运行:
#include"stdio.h"
#define N 10

/**************FOUND********/
int fun(int *a,int *b,int n)
{
    int *c,max=*a;
    for(c=a+1;c<a+n;c++)
       if(*c>max)
       {
               max=*c;
               /**************FOUND********/
               *b=c-a;
           }
           return max;
}

int main()
{
    int a[N],i,max,p=0;
    printf("Please enter 10 integers:\n");
    for(i=0;i<N;i++)           
       /**************FOUND********/
       scanf("%d",a[i]);
    /**************FOUND********/
    fun(a,&p,N);
    printf("max=%d,position=%d",max,p);
}

Q:为什么输入a[10]=0123456789,得到输出是max=1,position=6,程序功能没有得到实现啊?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-10-7 20:33

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表