每日三百行代码 第十三天
- L1-015 跟奥巴马一起画方块 (15 分)
- L1-016 查验身份证 (15 分)
- L1-017 到底有多二 (15 分)
- L1-033 出生年 (15 分)
- L1-030 一帮一 (15 分)
- L1-035 情人节 (15 分)
- L1-044 稳赢 (15 分)
- L1-048 矩阵A乘以B (15 分)
- L1-054 福到了 (15 分)
- L1-069 胎压监测 (15 分)
- L1-070 吃火锅 (15 分)
#include<stdio.h>
int main(){
char f;
int n;
scanf("%d %c",&n,&f);
for(int i=0;i<n/2+n%2;i++){
for(int j=0;j<n;j++){
printf("%c",f);
if(j==n-1){
printf("\n");
}
}
}
}
#include<stdio.h>
int main(void){
char num[18];
int sum;
char C;
int a[17] = {
7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
char z[11] = {
'1' ,'0' ,'X', '9' ,'8' ,'7' ,'6' ,'5' ,'4' ,'3' ,'2' };
int N;
while(scanf("%d",&N)!=EOF){
int t =N;
int cnt = 0;
while( t-- ){
sum = 0;
scanf("%s",&num);
int flag =0;
for(int i=0;i<=16;i++)
if( !( num[i] >='0' && num[i] <= '9' ) ){
flag = 1;
break;
}
if( flag == 0){
for(int i=0;i<=16;i++)
for( int j=0;j<=10;j++)
if( num[i] == '0'+j){
sum = sum + j * a[i];
break;
}
sum = sum %11;
if( z[sum] == num[17])
cnt++;
else {
for(int i=0;i<=16;i++)
printf("%c",num[i]);
printf("%c\n",num[17]);
}
if( cnt == N )
printf("All passed\n");
}
else if( flag == 1){
for(int i=0;i<=16;i++)
printf("%c",num[i]);
printf("%c\n",num[17]);
}
}
}
}
#include<stdio.h>
#include<string.h>
int main()
{
double a;
int i,n,j=0;
char b[52];
gets(b);
n=strlen(b);
for(i=0;i<n;i++){
if(b[i]=='2'){
j++;
}
}
if(b[0]=='-'){
a=1.5*j/(n-1);
}else{
a=1.0*j/n;
}
if(b[n-1]%2==0){
a=a*2;
}
printf("%.2f%%",a*100);
return 0;
}
#include<stdio.h>
int main(void){
int n,m,t1,t2,t3,t4,t,num;
while(scanf("%d %d", &n, &m) != EOF){
num=0;
while(1){
t=1;
t1=n/1000;
t2=n/100%10;
t3=n/10%10;
t4=n%10;
if(t1!=t2||t1!=t3||t1!=t4)
t++;
if(t1!=t2&&t1!=t3&&t2!=t3||t2!=t3&&t2!=t4&&t3!=t4||t1!=t4&&t1!=t3&&t4!=t3||t1!=t2&&t1!=t4&&t2!=t4)
t++;
if(t1!=t2&&t1!=t3&&t1!=t4&&t2!=t3&&t2!=t4&&t3!=t4)
t++;
if(t==m)
break;
n++;
num++;
}
printf("%d %d%d%d%d\n", num, t1, t2, t3, t4);
}
}
#include<stdio.h>
int main()
{
int i,n,u;
scanf("%d", &n);
int sex[51]={
0}, exist[51]={
0};
char name[51][9];
for (i = 0; i < n;i++)
{
scanf("%d %s", &sex[i], name[i]);
}
int x, y;
for (i = 0; i < n/2; i++)
{
for (u = n-1; u > (n-1) / 2; u--)
{
if (sex[i] != sex[u] && exist[u] == 0 && exist[i]==0)
{
printf("%s %s\n", name[i], name[u]);
exist[i]=exist[u] = 1;
}
}
}
return 0;
}
#include<stdio.h>
#include<string.h>
typedef struct{
char name[15];
}T;
int main(){
T t[14];
int i=0;
char a[]=".";
while(i<14){
scanf("%s",&t[i].name);
if(strcmp(t[i].name,a)==0){
break;
}
i++;
}
i--;
if(i<1){
printf("Momo... No one is for you ...");
return 0;
}
if(i>=1 && i<13){
printf("%s is the only one for you...",t[1].name);
return 0;
}
if(i>=13){
printf("%s and %s are inviting you to dinner...",t[1].name,t[13].name);
return 0;
}
return 0;
}
#include <stdio.h>
#include <string.h>
int main(){
int k = 0;
char s[20];
int cnt = 0;
scanf("%d", &k);
k++;
while(scanf("%s", s)){
if(strcmp(s, "End") == 0) break;
cnt++;
if(k == cnt){
printf("%s\n",s);
cnt = 0;
} else if(strcmp(s, "ChuiZi") == 0){
printf("Bu\n");
} else if(strcmp(s, "JianDao") == 0){
printf("ChuiZi\n");
} else if(strcmp(s, "Bu") == 0){
printf("JianDao\n");
}
}
return 0;
}
#include<stdio.h>
int main(){
int ra,ca,rb,cb;
scanf("%d%d",&ra,&ca);
int a[ra][ca];
for(int i=0;i<ra;i++){
for(int j=0;j<ca;j++){
scanf("%d",&a[i][j]);
}
}
scanf("%d%d",&rb,&cb);
int b[rb][cb];
for(int i=0;i<rb;i++){
for(int j=0;j<cb;j++){
scanf("%d",&b[i][j]);
}
}
if(ca!=rb){
printf("Error: %d != %d",ca,rb);
return 0;
}
int c[ra][cb];
for(int i=0;i<ra;i++){
int sum=0;
for(int j=0;j<cb;j++){
int sum=0;
for(int k=0;k<ca;k++){
sum+=(a[i][k]*b[k][j]);
}
c[i][j]=sum;
}
}
printf("%d %d\n",ra,cb);
for(int i=0;i<ra;i++){
for(int j=0;j<cb;j++){
printf("%d",c[i][j]);
if(j!=cb-1){
printf(" ");
}
}
if(i!=ra-1){
printf("\n");
}
}
return 0;
}
#include <stdio.h>
#include <math.h>
int i,j;
char ch[10000005];
int main()
{
int n,m;
scanf("%d %d",&n,&m);
int M=pow(26,n)-m;
while(n--){
ch[i++]='a'+M%26;
M/=26;
}
for(int j=i-1;j>=0;j--)
printf("%c",ch[j]);
return 0;
}
#include<stdio.h>
int n;
char ch,str[105][105];
int strcmp2(char *s1,char *s2){
for(int i=0,j=n-1;i<n/2&&j>n/2;i++,j--){
if(s1[i]!=s2[j])
return 1;
}
return 0;
}
int main(){
scanf("%c%d",&ch,&n);
getchar();
for(int i=0;i<n;i++){
for(int j=0;j<n;j++)
scanf("%c",&str[i][j]);
getchar();
}
int t=n/2;
int k;
for(k=0;k<t;k++){
if(strcmp2(str[k],str[n-k-1]))
break;
}
if(k==t)
printf("bu yong dao le\n");
for(int i=n-1;i>=0;i--){
for(int j=n-1;j>=0;j--){
if(str[i][j]=='@')
printf("%c",ch);
else
printf(" ");
}
printf("\n");
}
return 0;
}
# include <stdio.h>
int main() {
int a[5];
int min_num, cha;
scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]);
scanf("%d%d", &min_num, &cha);
int max = a[0];
for (int i = 1; i < 4; i++) {
if (max < a[i]) {
max = a[i];
}
}
int cnt = 0;
int index = 0;
for (int i = 0; i < 4; i++) {
if (max - a[i] > cha || a[i] < min_num) {
cnt++;
index = i;
}
}
if (cnt == 0) {
printf("Normal\n");
} else if (cnt == 1) {
printf("Warning: please check #%d!", index + 1);
} else if (cnt >= 2) {
printf("Warning: please check all the tires!\n");
}
return 0;
}
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char str[85];
int first_index = -1;
int s_count = 0;
int t_count = 0;
int main()
{
while(1){
gets(str);
if(strcmp(".",str)==0) break;
s_count++;
char * p = strstr(str,"chi1 huo3 guo1");
if(p != NULL){
if(first_index<0) first_index = s_count;
t_count++;
}
}
printf("%d\n",s_count);
if(t_count==0) printf("-_-#");
else printf("%d %d\n",first_index,t_count);
return 0;
}