#include <stdio.h>
#include <string.h>
#define LEN 16
int main(void)
{
char str1[LEN] = " ";
char str2[LEN] = " ";
static char *direction[] = {"キタ", "ホクセイ", "ニシ", "ナンセイ", "ミナミ", "ナントウ", "ヒガシ", "ホクトウ"};
static char *mode[] = {"mode:8", "mode:16"};
int num = 0;
int m = 0;
for(;;)
{
scanf("%d", &num);
strcpy(str1, direction[num]);
if (m == 1)
{
strcpy(str2, mode[m]);
}
else
{
strcpy(str2, mode[m]);
}
printf("%s\n", str2);
printf("%s\n", str1);
}
return 0;
}
2016年2月26日
2016年2月24日
strcpy()
#include <stdio.h>
#include <string.h>
#define LEN 16
int main(void)
{
char str1[LEN] = " ";
static char *direction[] = {"キタ", "ホクセイ", "ニシ", "ナンセイ", "ミナミ", "ナントウ", "ヒガシ", "ホクトウ"};
int num;
for(;;)
{
scanf("%d", &num);
switch(num)
{
case 0:
strcpy(str1, direction[0]);
break;
case 1:
strcpy(str1, direction[1]);
break;
case 2:
strcpy(str1, direction[2]);
break;
case 3:
strcpy(str1, direction[3]);
break;
case 4:
strcpy(str1, direction[4]);
break;
case 5:
strcpy(str1, direction[5]);
break;
case 6:
strcpy(str1, direction[6]);
break;
case 7:
strcpy(str1, direction[7]);
break;
}
printf("%s\n", str1);
}
return 0;
}
#include <string.h>
#define LEN 16
int main(void)
{
char str1[LEN] = " ";
static char *direction[] = {"キタ", "ホクセイ", "ニシ", "ナンセイ", "ミナミ", "ナントウ", "ヒガシ", "ホクトウ"};
int num;
for(;;)
{
scanf("%d", &num);
switch(num)
{
case 0:
strcpy(str1, direction[0]);
break;
case 1:
strcpy(str1, direction[1]);
break;
case 2:
strcpy(str1, direction[2]);
break;
case 3:
strcpy(str1, direction[3]);
break;
case 4:
strcpy(str1, direction[4]);
break;
case 5:
strcpy(str1, direction[5]);
break;
case 6:
strcpy(str1, direction[6]);
break;
case 7:
strcpy(str1, direction[7]);
break;
}
printf("%s\n", str1);
}
return 0;
}
登録:
投稿 (Atom)