#include<stdio.h>
struct in
{
unsigned int id : 8;
unsigned int zidx : 7;
unsigned int dq : 2;
unsigned int jc : 1;
unsigned int xt : 1;
};
void menu(void)
{
printf("(f) change font (s) change size (a) change alignment\n");
printf("(b) toggle bold (i) toggle italic (u) toggle underline\n");
printf("(q) quit\n");
}
int main(void)
{
char kg[2] = "uo";
char duiqi[3] = "lor";
struct in jiegou = {1, 12, 0, 0, 0};
char ch;
unsigned int m[10];
printf(" ID SIZE ALIGNMENT B I \n");
printf(" %u %u %c %c %c \n", jiegou.id, jiegou.zidx, duiqi[jiegou.dq], kg[jiegou.jc], kg[jiegou.xt]);
menu();
while (scanf("%c", &ch))
{
if (ch == 'q')
break;
if (ch == '\n')
continue;
switch(ch)
{
case 'f':
scanf("%u", &m[0]);
if (m[0] <= 255)
jiegou.id = m[0];
else
printf("滚\n");
break;
case 's':
scanf("%u", &m[0]);
if (m[0] <= 127)
jiegou.zidx = m[0];
else
printf("滚\n");
break;
case 'a':
scanf("%u", &m[0]);
if (m[0] <= 2)
jiegou.dq = m[0];
else
printf("滚\n");
break;
case 'b':
if (jiegou.jc == 1)
jiegou.jc = 0;
else
jiegou.jc = 1;
break;
case 'i':
if (jiegou.xt == 1)
jiegou.xt = 0;
else
jiegou.xt = 1;
break;
}
printf(" ID SIZE ALIGNMENT B I \n");
printf(" %u %u %c %c %c \n", jiegou.id, jiegou.zidx, duiqi[jiegou.dq], kg[jiegou.jc], kg[jiegou.xt]);
menu();
}
return 0;
}
cplus第六版第6题可行版
最新推荐文章于 2024-11-06 19:55:44 发布