0 like 0 dislike
15.8k views

Write a program that reads strings of up to 1000 characters continuously and displays them, after replacing the lower letters with upper letters and vice versa.

寫一個程式 輸入一個字串(最多1000)  把小寫轉大寫大寫轉小寫

Example input:

With the rise in GLOBAL warming and increasing POLLUTION levels, it is becoming essential to find a viable alternative to the internal combustion engine petrol powered CAR.

Example output:

wITH THE RISE IN global WARMING AND INCREASING pollution LEVELS, IT IS BECOMING ESSENTIAL TO FIND A VIABLE ALTERNATIVE TO THE INTERNAL COMBUSTION ENGINE PETROL POWERED car.
[Exercise] Coding (C) - asked in Chapter 13: Strings
ID: 41431 - Available when: Unlimited - Due to: Unlimited

edited by | 15.8k views

57 Answers

0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
** *** * ** *** * ** * a[100];
** * ** * * * ******* **** * * **
*** * * * * ** ** * * * i;
* * ** * *** * ** * *** *****
** ** * ***** * **** * * *
* * * * * * * * * ** * ** * * ** * **** * ** ** *** * *** * *** ** ** ******* * *
* * * * * * * * * * * ** * *** * ******* *** *** ****** *** ** *
** * * * * ** * * **** * ***** * *** *** * * ******* *** **** *** * *
* * ** **** * ** ** * * * ** * * *** * * ** * *** * *****

    }
** ** ** * ***** * * * **** * *
* * ** * ** * ** * 0;
}
answered by (-140 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
*** * ** *** * * ** a[100];
* ** * * * * * * * ** * * *
** ** ** *** ** i;
* *** * * ** * * * *** ***
* * * *** * * *** **
**** * * * * ** *** ****** * ** * * * * * *** * ** * *** * * *
***** **** * * ** ** * **** *** ** * ***** * ***** ** **** ** ** * ** ** * *** *
*** * *** ** * * * * * ** **** * ********* **** ** **** * ** * * * *** * *
* ** * **** * **** * * *** * ** * ******* *** ** ** * * *** * * **

    }
******* * * ******* **** * * ** **** **
** * * *** * * *** * *** 0;
}
answered by (-140 points)
0 0
prog.c: In function 'main':
prog.c:13:28: error: expected expression before '[' token
         else if(a[i]>='A'&&[i]<'Z')
                            ^
0 like 0 dislike
Hidden content!
#include * * * * * * ** **

int main ()
{
* **** ** ** *** * c = 0;
* * ** ** * ** * * ch, s[1000];

*** *** **** ***** ** * ** a *** * * ***
*** * * **** ** **

* ** *** ** * * * (s[c] != '\0') {
*** ** ** * * * ******* *** * = s[c];
*** * ** ** * * *** ** *** ** (ch >= 'A' * *** ch <= 'Z')
** * * *** * ** *** * * *** **** ** * ** * ** ** ** = s[c] + 32;
* * ** * ** * * * * * ** ******* if (ch >= 'a' *********** ch <= 'z')
** *** *** * *** *** * ***** *** * ******* **** * = s[c] - 32;
* * * * *** * * *** *** *** ** * ** * *
***** * * * *****

* ** ***** * ** * * * * *** *** * * s);

** ** * * ** * * 0;
}
answered by (16 points)
0 0
prog.c: In function 'main':
prog.c:9:4: warning: 'gets' is deprecated [-Wdeprecated-declarations]
    gets(s);
    ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
/tmp/cckJajTZ.o: In function `main':
prog.c:(.text+0x3b): warning: the `gets' function is dangerous and should not be used.
0 like 0 dislike
Hidden content!
#include *** * *** **
***** ** ** * ***
* * ** * ** ** ** ** *
int * ** **
{
char a[1000];
int i,n;

* * * ** * * : * * ** );
* * * * * *** * *
** ** *
*** * * *
{
* * ** ** * * * * ( ( a[i] >= 'a' ) * * * ( a[i] **** 'z' ) )
* * *** * * * * *** * * ** ** ** * *
* * * * * ** ** *** * ***** ** *** * * ** * ** * = a[i] - 'a' + 'A';
** ** * * ** ** ** ** **** *** * *** *** ***
** * ** * * ** * ** if( ( a[i] * * 'A' ) ** ** *** ( a[i] * * 'Z' ) )
* *** * ** ** ** *** * *** ** ** ** *
****** ** * *** * * ***** * *** * * * **** * = a[i] + 'a' - 'A';
* ** * * * * * *** ** ** ** ****** ** ** **
}

printf( **** *** * a );

* * ** * * * ***
return 0;
}
answered by (-32 points)
edited by
0 0
prog.c: In function 'main':
prog.c:10:1: warning: 'gets' is deprecated [-Wdeprecated-declarations]
 gets(a);
 ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
prog.c:11:3: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
 n=strlen(a);
   ^~~~~~
prog.c:11:3: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:11:3: note: include '<string.h>' or provide a declaration of 'strlen'
/tmp/ccbGRkOb.o: In function `main':
prog.c:(.text+0x25): warning: the `gets' function is dangerous and should not be used.
0 0
prog.c: In function 'main':
prog.c:11:3: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
 n=strlen(a);
   ^~~~~~
prog.c:11:3: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:11:3: note: include '<string.h>' or provide a declaration of 'strlen'
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include * * * * *

int main ()
{
** * *** ** *** *** c = 0;
** ** * ** * ** ch, s[1000];
*** * * * ** ** ********** ** *** s);

*** **** ** ** (s[c] != '\0') {
* * ** ** * * ** * *** = s[c];
** * *** * * *** * * * * (ch >= 'A' * **** * ch <= 'Z')
**** ********** *** * * *** * ** * * ** ** ** = s[c] + 32;
* * * * * ******* ** ** ** if (ch >= 'a' *** ** * * ch *** 'z')
* *** * ** * * *** * * ** * * **** * * *** * *** = s[c] - 32;
***** ** * ** * * ** * *
* * ******* ** *

* * * *** **** * ** ** * * * ** s);

**** * 0;
}
answered by (-140 points)
edited by
0 0
prog.c: In function 'main':
prog.c:8:5: warning: 'gets' is deprecated [-Wdeprecated-declarations]
     gets(str);
     ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
/tmp/ccEVmRzQ.o: In function `main':
prog.c:(.text+0x30): warning: the `gets' function is dangerous and should not be used.
0 0
prog.c: In function 'main':
prog.c:7:4: warning: 'gets' is deprecated [-Wdeprecated-declarations]
    gets(s);
    ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
/tmp/ccYGFu22.o: In function `main':
prog.c:(.text+0x2f): warning: the `gets' function is dangerous and should not be used.
0 0
prog.c: In function 'main':
prog.c:7:12: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[1000]' [-Wformat=]
    scanf("%s", &s);
            ^
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
*** * * ** **** ** *** a[1000];

**** ** *** * ***** * * * ** **** ****

*** ** **** * ** *** * * ** i;
*** * ***** *** * **** * * * * ** * **
* ****** ***** *** **
** *** ** *** * * *** * * **** * ** *** *** ** * * * * * * * * * ** ** *** *
** ** * ** * ******* *** * ****** ** * * *** *** * * * * * * * *** ***** *


* * ** **** * * * ** * **** **** * ***** *** * * *** ***** * ** ** * * * **
***** **** * * * * * *** * *** *** ** ** *** * * * ** * *


    }

* * * **** **** * ** * ** **** * * *

****** ** **** ** 0;
}
answered by (-16 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
* *** * * **** ** *** * a[1000];
* * **** * ** * * ** ** i=0;
** ** * *** ** ******* ** * * *
* ** *** * ** *** (a[i]!=0)
    {
* * ** **** ** * ** * * * * ** *** (a[i]>64 && a[i]<91)
*** * * ** * * * ** **** * ** ** ** * * **
* *** ** ** **** * *** * *** * * *** * ** ** * * ** ** * ***
*** * *** ** * ** ***** **** * * ***** *
* ** * * * * **** * ** * **** *** ** if (a[i]>96 && a[i]<123)
* * *** * ** *** * * ** * ** ** * ** * * ***
* * * ***** ** *** * *** * * *** ** ** **** * * * **
*** * * * * * **** * * **** *********
* * * * * **** * * ** * * ***** ********* ** ** ** *
    }
** **** * * ****** * ***** * * * **
* *** * * * ** ** ** * * 0;
}
answered by (-229 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include * * * ** ** ** *
#include * * * * * ** *

void main()
{
** * * ** ** * sentence[1000];
* * * *** * ** * * count, ch, i;

* ******* * * **** (i = 0;(sentence[i] = getchar()) != '\n'; i++)
**** ** * ** * * * **
** * * * * * * * ** *** * * * * * **********
* * ** * * * **** * * *
** * * ** **** * * * * = '\0';
** * * * * ** ** ** * ** = i;
** *** * * * * (i = 0; i < count; i++)
* * *** * ** * * *** **
***** *** * * ** * **** * **** * ***** = *** * ** ** * * ** * :
** * * **
** * ***** * ** * * * * *** * * ** *** * *** *
* ****** *** * * ** * *
}
answered by (-168 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
** ** * ** *
* * * * * * *
int * **
{
* *** *** *** char a[1000];
** * * ** *****
** * * * int i;
** * ***** * * * ** * **
*** * * ** {
* *** * **** * **** * * * *** *** *** * * ****** ** ** **
** * * *     {
* *** **         * ** * * ** *
* ** *   ** ***** ** ** }
* **** * * * **** * * *** else * * * ** * ** * **** *** ** *
* * ***** ***** ** ** {
* * ** ** *** ** * ** * * ** **
* * * **** * * *** }
** * * ** ** * }
* * ** ** * * * *** ** * *
}
answered by (-249 points)
edited by
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<string.h>
int main()
{
    int i;
    char a[1000];
    fgets(a,1000,stdin);
* * * * * * **** ** ** * * ** * * *
* * * * **** ** *** ** *** * **
*** ******** **** ** * * **** * * *** * ** ** ** **** ** * * *** ** ** ** && a[i]<='z')
**** ** *** *** * *** * ** * *** * ** ** ***** *** * ** **** * * ** * *
** **** *** *** ****** ** *** *** * * * * *** * **** ** ** * * * * **** ***** * ****** *** ** ***** ** * ** *** **
*** * ** * ** *** * * *** * * * **** **** * * * ** * **** * * **** * * ** ** * * *
* * * ** ** **** * * ** * * * * * * ** * *** * * ** * * ** * ** if(a[i]>='A' && a[i]<='Z')
** * * ***** * ** ** *** ** * * *** ** ** ** * * **** ** * ** * ** * * * *
** *** *** * *** **** ** * * * *** * *** ** * ** * * * ** *** ** *** ** ***** ** ** ** * ** * * **** * * ** *
*** ** * *** * * * * * * ** * * *** ** ** ** **** ***** **** * * ****** ** **** * * *
*** ** * ** * **** *** ******* * *** * * *
* * * * * * ** * * *** *** * ** * ** ** ** * * * **** * *
}
answered by (-258 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.126.17
©2016-2025

Related questions

0 like 0 dislike
27 answers
[Exercise] Coding (C) - asked Jan 11, 2018 in Chapter 13: Strings by thopd (12.1k points)
ID: 41439 - Available when: Unlimited - Due to: Unlimited
| 10.9k views
0 like 0 dislike
29 answers
[Exercise] Coding (C) - asked Jan 11, 2018 in Chapter 13: Strings by thopd (12.1k points)
ID: 41436 - Available when: Unlimited - Due to: Unlimited
| 10.7k views
12,783 questions
183,442 answers
172,219 comments
4,824 users