• C语言 寒假作业 01


    1

    print("HELLO WORLD!");
    

    2

    #include<stdio.h>
    		int main()
    	{
    		int n = 0;
    		scanf("%d", &n);
    		for (int i = 1; i <= n; i++)
    		{
    			for (int j = 1; j <= i; j++)
    			{
    				printf("%d*%d=%-4d", j, i, i * j);
    			}
    			printf("
    ");
    		}
    		return 0;
    	}
    }
    

    3

    #include<stdio.h>
    int main()
    {
    	int n = 0;
    	scanf("%d", &n);
    	for (int i = 1; i <= n; i++)
    	{
    		for (int j = 1; j <= n - i; j++)
    		{
    			printf(" ");
    		}
    		for (int k = 1; k <= i; k++)
    		{
    			printf("* ");
    		}
    		printf("
    ");
    	}
    	return 0;
    }
    

    4

    #include<stdio.h>
    int main()
    {
    	int n = 0, m[10][10] = { 0 }, a = 1, s = 0;
    	scanf("%d", &n);
    	for (int i = 0; i < n; i++)
    	{
    		s = i;
    		for (int j = 0; j <= i; j++)
    		{
    			m[s][j] = a;
    			a++;
    			s--;
    		}
    	}
    	for (int i = 0; i < n; i++)
    	{
    		for (int j = 0; j < n - i; j++)
    		{
    			printf("%-3d", m[i][j]);
    		}
    		printf("
    ");
    	}
    	return 0;
    }
    

    5

    #include<stdio.h>
    int main()
    {
    	int num1 = 0, num2 = 0, num[100] = {0},sum=0,i=1;
    
    	scanf("%d %d", &num1, &num2);
    	sum = num1;
    
    	while (sum > 1)
    	{
    		for (int j = 0; j < num1; j++)
    		{
    			if (num[j] == 1)
    				continue;
    			if (i == num2)
    			{
    				num[j] = 1;
    				i = 1;
    				sum--;
    				continue;
    			}
    			i++;
    		}
    	}
    	for (int j = 0; j < num1; j++)
    	{
    		if (num[j] == 0)
    		{
    			printf("%d", j+1);
    			break;
    		}
    	}
    	return 0;
    }
    

    6

    #include<stdio.h>
    int main()
    {
    	int a[100] = { 0 },len=0,j=0,num=0;
    
    	while (scanf("%d", &a[len]) != EOF)
    	{
    		len++;
    		for (int i = 1; i < len; i++)
    		{
    			j = i - 1;
    			num = a[i];
    			while (j >= 0 && a[j] > num)
    			{
    				a[j + 1] = a[j];
    				j--;
    			}
    			a[j+1] = num;
    		}
    
    	}
    	for (int i = 0; i < len; i++)
    	{
    		printf("%d ", a[i]);
    	}
    	return 0;
    }
    

    7

    #include<stdio.h>
    #include<string.h>
    int main()
    {
    	char a[1000], b[1000];
    	int A[1000] = { 0 }, B[1000] = { 0 }, sum[1000] = {0}, len_a = 0, len_b = 0,j=0,num=0;
    
    	scanf("%s %s", &a, &b);
    	len_a = strlen(a);
    	len_b = strlen(b);
    	for (int i = 0; i < len_a; i++)
    	{
    		A[i] = a[len_a-i-1] - 48;
    	}
    	for (int i = 0; i < len_b; i++)
    	{
    		B[i] = b[len_b-i-1] - 48;
    	}
    	while (len_a > 0 || len_b > 0)
    	{
    		sum[j] = sum[j]+A[j] + B[j];
    		if (sum[j] >= 10)
    		{
    			num = sum[j];
    			sum[j] = num % 10;
    			sum[j + 1] = num / 10;
    		}
    		len_a--;
    		len_b--;
    		j++;
    	}
    	for (int i = j - 1; i >= 0; i--)
    	{
    		printf("%d", sum[i]);
    	}
    	return 0;
    }
    
  • 相关阅读:
    树的直径 学习笔记
    SDOJ 3742 黑白图
    【SDOJ 3741】 【poj2528】 Mayor's posters
    SDOJ 3740 Graph
    SDOJ 3696 Tree
    SDOJ 1195 Zhenhuan
    又一次受刺激后的发奋
    html_表单form中的input类型大集合
    js_表格的增删改
    JS_拖拽窗口的实现
  • 原文地址:https://www.cnblogs.com/love0017/p/14285657.html
Copyright © 2020-2023  润新知