科锐C语言-作业03(循环控制)

1.用十进制、八进值、十六进制、字符形式输出ASCII码表33~126中的代码。

#include <stdio.h>
main()
{
	int i=33;
	while(i<=126)
	{
		printf("%d,%o,%x,%c\n",i,i,i,i);
		i++;
	}
}

2.计算1!+2!+… …+10!的值

#include <stdio.h>
main()
{
	int i=1,n=1,sum=0;
    for(i=1;i<=10;i++)
	{
		n=n*i;
		sum=sum+n;	
	}
	printf("1!+2!+… …+10!的值为:%d\n",sum);
}

3.用循环的嵌套输出下方图形:

*
***
*****
*******
*********
***********

#inclu
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
期末作业要求如下: Write a program that will help elementary school pupils practice math. a) The program will first ask the user for his/her ID number (including two letters & 4 digits), e.g. Please input your four digit ID no: AB1234 The program should have input validation. Then the program prompts three choices: (1) Start a test (2) Check scores (3) Exit Test: the program will give 10 math problems, e.g.: 12 * 3 = 36 48 + 32 = 80 … 56 / 28 = 2 Note: i) Pupils will answer each problem before the next one is given. ii) The problems should include addition, subtraction, multiplication and division. They are randomly generated. iii) Randomly generates numbers for problems. However, must ensure that both the problem and the result are no larger than two digits. The problem and the result should be greater than or equal to zero. The divisor cannot be zero. iv) After ten problems are finished, record the time used by the student to do the ten problems. v) Gives a score to each student. Saves this student’s ID, his/her score and the time used into a file named ‘record.txt’. vi) Print the following information on the screen: Prob. | Correct Answ. | Ur Answ c) Check scores: Searches the file ‘record.txt’ and lists all the historical scores for this student, e.g.: Your previous records are: AB1234 80 150 seconds AB1234 50 182 seconds AB1234 90 98 seconds You will be marked based on your program’s: (1) Correctiveness (2) Readability (3) Robustness (4) Conciseness 目前本人的程序可以直接使用,并完全满足要求。还是建议学弟学妹在字里行间多多理解,争取自己写出漂亮的代码! 向本人在完成此作业过程中参考的代码示衷心的感谢!

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值