質問編集履歴

5

回答者の方の関数を参考にしてみました。

2019/02/20 15:09

投稿

shimchan
shimchan

スコア15

test CHANGED
File without changes
test CHANGED
@@ -20,11 +20,13 @@
20
20
 
21
21
  #include<stdio.h>
22
22
 
23
- #include <string.h>
23
+ #include<string.h>
24
+
25
+ #include<ctype.h>
24
26
 
25
27
 
26
28
 
27
- main(int argc,char *argv[]){
29
+ int main(int argc,char *argv[]){
28
30
 
29
31
  char *str = argv[1];
30
32
 
@@ -32,11 +34,11 @@
32
34
 
33
35
  for(i = 0;i<strlen(str);i++){
34
36
 
35
- if(str[i]>='A'&&str[i]<='Z'){
37
+ if(islower(str[i])){
36
38
 
37
39
  str[i]--;
38
40
 
39
- }else if(str[i]>='a'&&str[i]<='z'){
41
+ }else if(isupper(str[i])){
40
42
 
41
43
  str[i]--;
42
44
 
@@ -45,6 +47,8 @@
45
47
  }
46
48
 
47
49
  printf("%s\n",str);
50
+
51
+ return 0;
48
52
 
49
53
  }
50
54
 

4

訂正

2019/02/20 15:09

投稿

shimchan
shimchan

スコア15

test CHANGED
File without changes
test CHANGED
@@ -18,9 +18,9 @@
18
18
 
19
19
  ソースコード
20
20
 
21
- /#include<stdio.h>
21
+ #include<stdio.h>
22
22
 
23
- /#include <string.h>
23
+ #include <string.h>
24
24
 
25
25
 
26
26
 
@@ -50,7 +50,7 @@
50
50
 
51
51
 
52
52
 
53
-
53
+ ```
54
54
 
55
55
  ### 試したこと
56
56
 

3

少し改良しました。

2019/02/20 14:56

投稿

shimchan
shimchan

スコア15

test CHANGED
File without changes
test CHANGED
@@ -30,7 +30,7 @@
30
30
 
31
31
  int i;
32
32
 
33
- for(i = 0;i<strlen[str];i++){
33
+ for(i = 0;i<strlen(str);i++){
34
34
 
35
35
  if(str[i]>='A'&&str[i]<='Z'){
36
36
 

2

改めて書き直し

2019/02/20 14:47

投稿

shimchan
shimchan

スコア15

test CHANGED
File without changes
test CHANGED
@@ -18,9 +18,9 @@
18
18
 
19
19
  ソースコード
20
20
 
21
- #include<stdio.h>
21
+ /#include<stdio.h>
22
22
 
23
- #include <string.h>
23
+ /#include <string.h>
24
24
 
25
25
 
26
26
 

1

ソースコードの追加

2019/02/20 14:46

投稿

shimchan
shimchan

スコア15

test CHANGED
File without changes
test CHANGED
@@ -18,7 +18,37 @@
18
18
 
19
19
  ソースコード
20
20
 
21
+ #include<stdio.h>
22
+
23
+ #include <string.h>
24
+
25
+
26
+
27
+ main(int argc,char *argv[]){
28
+
29
+ char *str = argv[1];
30
+
21
- ```
31
+ int i;
32
+
33
+ for(i = 0;i<strlen[str];i++){
34
+
35
+ if(str[i]>='A'&&str[i]<='Z'){
36
+
37
+ str[i]--;
38
+
39
+ }else if(str[i]>='a'&&str[i]<='z'){
40
+
41
+ str[i]--;
42
+
43
+ }
44
+
45
+ }
46
+
47
+ printf("%s\n",str);
48
+
49
+ }
50
+
51
+
22
52
 
23
53
 
24
54