二轮复习2

在这里插入图片描述


#include<stdio.h>
#include<string.h>
#include<math.h>


int main()
{
	int a[3][3], b[3][3], c[3][3];
	int i, j, k, n, m, x, y;
	for (x = 0; x < 3; x++)
	{
		for (y = 0; y < 3; y++)
			scanf("%d", &a[x][y]);
	}

	for (x = 0; x < 3; x++)
	{
		for (y = 0; y < 3; y++)
			scanf("%d", &b[x][y]);
	}

	for (i = 0; i < 3; i++)
		for (j = 0; j < 3; j++)
			c[i][j] = 0;

	for (i = 0; i < 3; i++)
	{

		for (j = 0; j < 3; j++)
		{
			for (k = 0; k < 3; k++)		//第三个k
				c[i][j] += a[i][k] * b[k][j];	//核心代码写法
		}
	}
	for (m = 0; m < 3; m++)
	{
		for (n = 0; n < 3; n++)
			printf("%d ", c[m][n]);
		printf("\n");

	}
}


在这里插入图片描述


#include<stdio.h>
#include<string.h>
#include<math.h>


int main()
{
	int n,i,j,a,b;
	char x[101][50],y[50];
	while(scanf("%d", &n) != EOF)
	{
		for (i = 0; i < n; i++)
		{
			scanf("%s", &x[i]);
		}
		for(j=0;j<n;j++)
			for (a = 0; a < n - 1; a++)		//必须到n-1就停止
			{
				if (strcmp(x[a], x[a + 1]) > 0) //strcmp(s1,s2) 判断两个字符串s1和s2是否相同
				{								//若str1<str2,则返回负数;
												//若str1 > str2,则返回正数。
					strcpy(y ,x[a]);			//y只是传值排序
					strcpy(x[a], x[a + 1]);
					strcpy(x[a + 1], y);
				}
			}
		for (b = 0; b < n; b++)
			printf("%s\n", x[b]);
		return 0;
	}
}


在这里插入图片描述

#include<stdio.h>
#include<string.h>
#include<math.h>


int main()
{
	int m, k, i,j,c=0,n;
	int flag = 0;
	while (scanf("%d %d", &m, &k)!=EOF)
	{ 
		flag = 0;
		for (i = m+1; i > m; i++)
		{
			if (flag == 1)
				break;
			n = sqrt(i);
			for(j=2;j<=n;j++)
			{
				if (i%j == 0) break;
				if (j >= n)
				{
					c++;
					if (c < k)
						printf("%d ", i);
					if (c == k)
						printf("%d\n", i);
					if (c > k)
						flag = 1;
				}
			}
		}
	}
	return 0;

}


#include<stdio.h>
#include<string.h>
#include<math.h>


int main()
{
	char a[37];
	int n,i,j,k,s;		//错在写太复杂了 其实很简单
	scanf("%s", &a);

	s = strlen(a);
	scanf("%d", &n);
	
	for (j = s - n; j < s; j++)
	printf("%c", a[j]);
	for (j = 0; j < s - n; j++)
		printf("%c", a[j]);
	printf("\n");
	return 0;
}

在这里插入图片描述

#include<stdio.h>
#include<string.h>
#include<math.h>


void sort(char a[][1000], int n, char b[][1000])
{
	int i, j;
	char str[1000];
	for (i = 0; i < n-1; i++)
	{
		for (j = 0; j < n - 1; j++)
		{
			if (strcmp(a[j], a[j + 1]) > 0)
			{
				strcpy(str, a[j]);
				strcpy(a[j], a[j + 1]);
				strcpy(a[j + 1], str);
			}
		}
	}
	for (i = 0; i < n; i++)
	{
		strcpy(b[i], a[i]);
	}
}

void len_sort(char a[][1000], int n)
{
	int i, j, len1, len2;
	char str[1000];
	for (i = 0; i < n - 1; i++)
	{
		for (j = 0; j < n - 1; j++)
		{
			if ((len1 = strlen(a[j])) > (len2 = strlen(a[j + 1])))
			{
				strcpy(str, a[j]);
				strcpy(a[j], a[j + 1]);
				strcpy(a[j + 1], str);
			}
		}
	}
	for (i = 0; i < n; i++)
	{
		if (i == 0)
			printf("%s", a[i]);

		else
			printf(" %s", a[i]);
	}
	printf("\n");
}
int main()
{
	char a[100][1000], b[100][1000];
	int n, i;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%s", a[i]);
	sort(a, n, b);
	len_sort(a, n);
	for (i = 0; i < n; i++)
	{
		if (i == 0)
			printf("%s", b[i]);
		else
			printf(" %s", b[i]);
	}
	printf("\n");
	return 0;
}

在这里插入图片描述

int main()
{
	int n,i,j;
	scanf("%d", &n);
	for (i = 1; i <= n; i++)
	{
		printf("%d", i);
		for (j = 0; j < n - 1; j++)
			printf(" %d", (i + j) % n + 1);	//核心代码建议看f10
		printf("\n");
	}
}

在这里插入图片描述

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main()
{
    char a;
    int num=0,chac=0,space=0,other=0;
    while((a=getchar())!='\n')		//getchar不需要用for了!
    {
            if(a>='a'&&a<='z'||a>='A'&&a<='Z')
                chac++;
            else if(a>='0'&&a<='9')
                num++;
            else if(a==' ')
                space++;
            else
                other++;
    }
        printf("%d %d %d %d\n",chac,num,space,other);

    return 0;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值