ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

实验2

2022-04-17 18:00:06  阅读:32  来源: 互联网

标签:include int scanf else 实验 printf main


#include<stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 5
int main() {
	int grade, number; int i; 
	srand(time(0)); // 以当前系统时间作为随机种子 
	for(i=0; i<N; ++i)
	{ grade = rand()%4 + 2018;//随机生成学号的前四位,即年级
	number = rand()%999 + 1;//随机生成学号的后三位序号
	printf("%d8330%04d\n", grade, number);
	}return 0; }//程序的功能是随机生成学号

#include<stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int luck, n,c;
luck = rand() % 30 + 1;
printf("请猜幸运日哦");
for (n = 1; n <= 3; n++)
{

scanf_s("%d", &c);
if (luck == c)
{
printf("\n恭喜你猜对了"); break;
}
else
if (n != 3)
printf("\n不好意思,你猜错了哦,再试一次吧");
else
continue;

}
if (n==4)
printf("\n你没有机会了,luckyday是%d日哦", luck);
else
printf("拜拜!");
return 0;
}

 

  

#include<stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
	char n;
	while (scanf_s("%c", &n) != EOF)
	{
		getchar();
		if (n == 'r')
			printf("stop!"); 
		else

			if (n == 'g')
				printf("go go go"); 
			else

				if (n == 'y')
					printf("wait a minute"); 
				else
					printf("something may be wrong.");
	}
	return 0;
}

  

 

 

 

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

int main()
{
	int i, n, a, k; double s;
	while (scanf_s("%d%d", &n, &a) != EOF)
	{
		k = 0; s = 0;
		for (i = 1; i <= n; i++)
		{
			k = k * 10 + a;
			s += 1.0 * i / k;
		}
		printf("n=%d,a=%d,s=%f\n\n", n, a, s);
	}
	return 0;
}

  

 

  

#include<stdio.h>

#define N 9

int main()
{
	int i, j;
	for (i = 1; i <= N; i++)
	{
		for (j = 1; j <= i; j++)
		{
			printf("%d×%d= %2d  ", j, i, i * j);
		}
		printf("\n");
	}
	return 0;
}

  

#include<stdio.h>

int main()
{
	int n,i;
	scanf("%d",&n);
	printf("input n:%d\n",n);
	
	for(i=1;i<=n;i++)
	{
	printf(" o \n");
	printf("<H>\n");
    printf("I I\n\n");
    }
    return 0;
}

  

#include<stdio.h>

int main()
{
	int i, n;
	scanf_s("%d", &n);
	printf("input n:%d\n", n);

	for (i = 1; i <= n; i++)
	{
		printf(" o   ");
	}
	printf("\n");
	for (i = 1; i <= n; i++)
	{
		printf("<H>  ");
	}
	printf("\n");
	for (i = 1; i <= n; i++)
	{
		printf("I I  ");
	}
	return 0;
}

  

 

标签:include,int,scanf,else,实验,printf,main
来源: https://www.cnblogs.com/xcy1234/p/16135427.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有