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;
}