0 thích 0 k thích
20.8k đã xem

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) - đã hỏi trong Chapter 13: Strings
ID: 41431 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn

đã sửa bởi | 20.8k đã xem

57 Trả lời

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

    }
* * * * ** * **** * ***** ** * * * ***
* ******** *** * ** ******** 0;
}
trả lời bởi (-140 điểm)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 thích 0 k thích
Hidden content!
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
** * ***** * * * ** * a[100];
** * * ** * ** *** ** * ***
* * * *** **** **** i;
******* ** * * * ** * ** * *** * * ***
***** * ********* * * ****
** * * ** *** * *** *** * * ** *** *** **** * ** **** * * * ** ***
*********** *** * ****** * *** * * *** **** * ** *** *
* *** * * ****** * * * * *** * ** *** * * ** * * *** ***** * ** * * ** * ** **
** * **** *** * ** * * ** *** *** * ** **** ** ** * * * * ** * *

    }
** * * * * ** * * * ****** * * **
* * * * **** ***** * ** * * ** 0;
}
trả lời bởi (-140 điểm)
0 0
prog.c: In function 'main':
prog.c:13:28: error: expected expression before '[' token
         else if(a[i]>='A'&&[i]<'Z')
                            ^
0 thích 0 k thích
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;
}
trả lời bởi (16 điểm)
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 thích 0 k thích
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;
}
trả lời bởi (-32 điểm)
đã sửa bởi
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 thích 0 k thích
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;
}
trả lời bởi (-140 điểm)
đã sửa bởi
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 thích 0 k thích
Hidden content!
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

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

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

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


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


    }

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

** * ** ** ***** ** *** 0;
}
trả lời bởi (-16 điểm)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 thích 0 k thích
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;
}
trả lời bởi (-229 điểm)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 thích 0 k thích
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++)
* * **** * * ** * * *** *
** * * *** * * ** * * * ** ** * = *** ** * ** * *** :
*** * * * * ***
*** * **** * *** *** * * ******* * * * ** *
* * ** * * * **** *
}
trả lời bởi (-168 điểm)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 thích 0 k thích
Hidden content!
** *** **** * **
****** * ***** *
int *** ****
{
* **** ** *** char a[1000];
* * ** ** * * * ** * *
*** ** * int i;
* **** * * *** * * * **
* ** {
** ** * * * * * * * *** ** *
** ** * ***     {
** *         ** ** *****
*   * ** ** ** * * }
** * ** ** * ** * *** * else * ** **** * * ** ** ** **
* *** * ** * * * {
* * * **** * * * * * * ***** * *** * **
* * * * * ** * }
* **** * * }
* ** * * ** * * ******* **
}
trả lời bởi (-249 điểm)
đã sửa bởi
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 thích 0 k thích
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')
** * ** * *** * *** * * ** ** * **** ** * **** * * ****** * ** *** * *** ** *** **** ** ** **** *
** * * * ** ****** * * * * * *** ** ***** * **** ***** * ** ** * ** *** *** ** * ** * ** * * * *** *** *****
*** * ** *** ** *** *** * * ***** * ** * * * * *** *** * ** * * ******* * * * *
** * * **** * ** *** *** * * * * * * * *
** ** ** ****** *** * ** * * **** ***** ** ** * *** *** * **
}
trả lời bởi (-258 điểm)
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:104.23.197.238
©2016-2026

Những câu hỏi liên quan

0 thích 0 k thích
27 trả lời
[Exercise] Coding (C) - đã hỏi ngày 11 tháng 1 năm 2018 trong Chapter 13: Strings bởi thopd (12.1k điểm)
ID: 41439 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 14.5k đã xem
0 thích 0 k thích
29 trả lời
[Exercise] Coding (C) - đã hỏi ngày 11 tháng 1 năm 2018 trong Chapter 13: Strings bởi thopd (12.1k điểm)
ID: 41436 - Xem được từ: Không giới hạn - Hiệu lực đến: Không giới hạn
| 13.5k đã xem
12,783 câu hỏi
183,442 trả lời
172,219 bình luận
4,824 thành viên