输入a.老师的名字,b.你的名字,c.食物,d.数字,e.形容词,f.颜色,g.动物,输出请假条 Dear Instructor [Instructor name], I am sorry that I am unable to turn in my homework at this time. First, I ate a rotten [food], which made me turn [color] and extremely ill. I came down with a fever of [number]. Next, my [adjective] pet [animal] must have smelled the remains of the [food] on my homework, because he ate it. I am currently rewriting my homework and hope you will accept it late. Sincerely, [Your name]
1 2 3 4 5 6 7
#include<cstdio> char s[10][100]; intmain(){ for(int i = 1; i <= 7; i++) scanf("%s", s[i]); printf("Dear Instructor %s,\nI am sorry that I am unable to turn in my homework at this time. First, I ate a rotten %s, which made me turn %s and extremely ill. I came down with a fever of %s. Next, my %s pet %s must have smelled the remains of the %s on my homework, because he ate it. I am currently rewriting my homework and hope you will accept it late.\nSincerely,\n%s", s[1], s[3], s[6], s[4], s[5], s[7], s[3], s[2]); }
太长了可读性下降,于是变成了下面的,将就着看吧
1 2 3 4 5 6 7 8 9 10
#include<cstdio> char s[10][100]; intmain(){ for(int i = 1; i <= 7; i++) scanf("%s", s[i]); printf("Dear Instructor %s,\nI am sorry that I am unable to turn in my homework at this time. ", s[1]); printf("First, I ate a rotten %s, which made me turn %s and extremely ill. ", s[3], s[6]); printf("I came down with a fever of %s. Next, my %s pet %s must have ", s[4], s[5], s[7]); printf("smelled the remains of the %s on my homework, because he ate it. ",s[3]); printf("I am currently rewriting my homework and hope you will accept it late.\nSincerely,\n%s",s[2]); }