POLITO COMPUTER SCIENCE lab numero uno

**这玩意纯属于自己练习时候写的而且没写完,别介意写成啥样。

Draw the flow-chart to determine if a number is a prime number; in particular, the solution must :
满足以下条件
a) Acquire using the keyboard an integer value
通过键盘来输入一个实数
b) Use the simple structures while - do or do - while to determinate, using a loop, if the number is a prime number
使用do-while或者while-do来判断是否是一个prime number(素数:既除其本身和1无任何公约数)
c) Print in the screen a message depending on the cases.
用switch case将其显示在屏幕上

#include
int main()
{
	printf("pls int the value! \n");
	int num, temp = 1,result,mark=1;
	scanf("%d", &num);
	if (num==0)
	{
		printf("shouldn't be 0!");
		return 0;
	}
	else if(num == 1)
	{
		printf("it is 1!");
		return 0;
	};
	do
	{
		temp++;
		result = num % temp;
		if (result==0)// 等于0的话代表着能被整出
		{
			mark = 0;
		}
	} while (temp

Write a C program that defines 3 integer variables called operand1, operand2 and result. The program must:
写一个C语言程序:定义三个值:operand1, operand2 和result.
a) Acquire using the keyboard the values of operand1 e operand2 using the scanffunction
通过键盘和scanf函数来输入operand1 和 operand2的数值。
b) Compute the sum of operand1 and operand2 and save it in the result variable
求其和并保存在result中
c) Display on the screen the value of the result variable using the printf function
然后在用printf函数将其打印在屏幕上

int main()
{	
		int operand1, operand2, result;
		printf("pls int two value!");
		scanf("%d %d", &operand, &operand);
		result = operand1 + operand2;
		printf("%d", result);
		return 0;
}

Write a C program able to solve a first degree equation given in the form ax + b = 0;
the program must :
写一个计算ax+b=0程序
a) Define two integer values(int), a and b to store the coefficients of the equation
定义 a和b
b) Define an integer variable x in order to store the result of the equation
定义一个x来储存结果
c) Acquire using the keyboard the value of the coefficients a and b
在键盘上输入a和b的值;
d) Compute the value x and display it on the screen.
计算出x的值
In - depth: consider, among the others, the case in which the value a is equal
to 0.注意a=0的情况

*/

#include
int main()
{
	int a;
	int b;
	float x;
	printf("pls int a and b\n");
	scanf("%d %d", &a, &b);
	if (a==0)/*这里是a=0时候的处理*/
	{
		printf("a shoulden't be zero!");
		return 0;
	};
		x = -b / a;
	printf("x is %f", x);
	return 0;

你可能感兴趣的:(笔记,都灵理工大学,笔记,瞎写,真的瞎写,实在是瞎写,我就是在瞎写)