首页 > > 详细

代写program、代做C++编程设计

项目预算:   开发周期:  发布时间:   要求地区:
Computer Programming
Preparation
• Group size: individual
• Download and install any C compiler you like and Python interpreter on
your computer. For this purpose, we have videos to show you how to do this
for Python. Regarding C, perhaps the simplest way is to install Dev-C++
(one may download it from its official website: https://www.bloodshed.net/)
if you use Windows. But for Mac users, you may need do some search on
Bilibili, Youtube, or Google to install a C compiler. For example, now
a popular way to program in C on Mac is to use “Visual Studio Code +
gcc”. (Of course, one may also use Visual Studio Code to program in C on
Windows.)
• One may also use online C/Python compiler/interpreter. But in this way,
the difference between compilers and interpreters becomes less clear.
Aim
In this lab, you will learn how to program a computer. Moreover, you will
understand what is the difference between compiler and interpreter.
Your task
Convert the four flowcharts (i.e. HelloWorld.rap, AbsoluteValue.rap, Sum.rap,
and Search.rap) given to you in our lab on Raptor into C programs and Python
programs, respectively.
Toy examples
I hope that the codes given below cover most syntaxes of C and Python that
are needed for writing down the required programs. You need to combine/adapt
these codes in a new/creative way.
1. How to first read an integer from the keyboard and then print it on the
screen?
C program:
#include
int main() {
int number;
/* This is a comment that will not be regarded as a part of the program
by the compiler: "number" is a variable. You can change the name "number"
to virtually any other name (as long as it is a concatenation of English
letters and numbers but beginning with a letter) which you prefer to. */
printf("Enter an integer: ");
1
// reads and stores input
scanf("%d", &number);
// displays output
printf("You entered: %d", number);
return 0;
}
Python program:
number = int(input("Enter an integer: "))
print("You entered:", end = " ") # The purpose of "end = " "" is to avoid new line
print(number)
2. A simple if statement
C program:
#include
int main()
{
int score;
score = 71; // You can change the value of score here to test this program
if (score >= 60)
printf("Pass");
else
printf("Fail");
return 0;
}
Python program:
score = 71
if score > 59:
print("Pass")
else:
print("Fail")
3. A simple while statement
C program:
#include
2
int main()
{
int i;
int m;
i = 1;
m = 100; // The value of the variable m can be changed to input from the keyboard
while (i != m)
{
printf("%d ", i);
i = i + 1;
}
return 0;
}
Python program:
i = 1
m = 100
while i <= m:
print(i, end = " ")
i = i + 1
4. How to initialize an array of integers?
C program:
#include
int main()
{
int a[100];
int i;
i = 0;
while (i < 100) // Note that the index of arrays begins with 0 (as opposed to 1)
{
a[i] = 0;
printf("a[%d] = %d ", i, a[i]);
i = i + 1;
}
return 0;
}
3
Python program:
i = 0
a = []
while i <= 99:
a.append(0)
print("a[", end = "")
print(i, end = "")
print("] = ", end = "")
print(a[i], end = " ")
i = i + 1
Submission
All C source codes (.c files) and corresponding objective codes (i.e. .exe files on
Windows or .app files on MacOS), and all Python source codes (i.e. .py files)
Further materials (for self-motivated students)
Havard course: CS50: Introduction to Computer Science
MIT course: Introduction to Computer Science and Programming in Python,
on OCW or edX
4

软件开发、广告设计客服
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 9951568
© 2021 www.rj363.com
软件定制开发网!