《C语言外语学习.pptx》由会员分享,可在线阅读,更多相关《C语言外语学习.pptx(34页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Lab Schedule and PolicyEvery Wednesday or by appointment;Totally 24 hours,2 hours per week;Please be sure to get in the lab on time;Assignment will be shown in the class on the morning of the same day;Some assignments will be graded;It is a good habit to write the program on paper prior the lab time
2、;Please write your program carefully and independently.1第1页/共34页Programming Environment2第2页/共34页Assignment#1Write a program to show the following sentences:I am a student.I love China.3第3页/共34页Assignment#1Write a program to show the following figure:4第4页/共34页Assignment#1Given the values of three var
3、iables a=2,b=4,c=7,write a program to calculate the sum of a,b and c;compute and output the value of variable x,where x=a/(b c)The result should be like the figure shown below:5第5页/共34页Assignment#2Write a program to get the values of integer a and b from the keyboard,and then calculate the results o
4、f a+b,a b,a*b,a/b and a%b respectively.6第6页/共34页Assignment#2Input the bottom length and height of a triangle,output the area of this triangle(Reserve two effective digits).7第7页/共34页Assignment#2Input five integers from the keyboard,and then output the minimum number among them.8第8页/共34页Assignment#3In
5、put n from keyboard,and calculate n!9第9页/共34页Assignment#3Print the first 20 Fibonacci Numbers.10第10页/共34页Assignment#3Print all the“Daffodils Number”between 100 999.11第11页/共34页Assignment#3Input several numbers from keyboard,print the max number among them.12第12页/共34页Assignment#4Write a function to re
6、turn the maximum number in five numbers,you can use the function getMax(int a,int b,int c)two times.13第13页/共34页Assignment#4Write a program to accept two numbers from the keyboard,and then print the greatest common divisor(最大公约数)and the least common multiple(最小公倍数)using functions.14第14页/共34页Assignmen
7、t#4Calculate 1+2+n using nested calls of functions.15第15页/共34页Assignment#4Calculate 1+2+n using recursive calls of functions.16第16页/共34页Assignment#5Input several numbers,and output its reverse.17第17页/共34页Assignment#5Input a string,output the number of words it contains.18第18页/共34页Assignment#5Write a
8、 program to accept a string and a character,and then delete each element which is equal to the character from the array.19第19页/共34页Assignment#5Write a program to implement the following questions:Define a function void input(int s,int n)to get ten integers into an array;Define a function void sort(i
9、nt s,int n)to sort these integers in the array;Define a function void print(int s,int n)to output the sorted numbers in the array;Finally,write appropriate main function to test your program.20第20页/共34页Assignment#6Use the arrays of structures to store five students information including id,name and
10、score,input the information from the keyboard,output the information of the student with the maximum score,then sort these students by scores from low to high,finally,output information of these students.21第21页/共34页22第22页/共34页Assignment#6Write a function void decrement(int*a)to decrease the value of
11、 the argument in the main function by 1.You should use pointer as parameter to the function decrement23第23页/共34页Assignment#7Write a function void decrement(int*a)to decrease the value of the argument in the main function by 1.You should use pointer as parameter to the function decrement.Similarly,wr
12、ite a function swap to exchange the values of two variables outside the function24第24页/共34页Assignment#7Input n from the keyboardInput n numbers from the keyboard and store them to a dynamically allocated arraySort these numbers using any of the sorting algorithmsOutput the sorted numbers to the scre
13、enFinally,output these sorted numbers to a file named“output.txt”25第25页/共34页Assignment#8Input n from the keyboardInput n students data from the keyboard and store them to a dynamically allocated array of structuresOutput the student that has the maximum grade to the screenSort these students data by
14、 score from low to highFinally,output these data to a file named“output.txt”26第26页/共34页Assignment#9Write a program to implement the following questions.Input the size for the first array;Input the size for the second array;Input the numbers for the first and the second array;Output he numbers which
15、the first array has but the second array does not have;Output the numbers which the second array has but the first array does not have;Output the common elements of the two arrays;27第27页/共34页Assignment#928第28页/共34页Assignment#10Write a program to implement the address book using dynamic singly linked
16、 list,the node should contain name,address and phone#:Write a function create to store three peoples information into the singly linked list;Write a function print to print these information to the standard output;Write a function search to find the telephone number of a contact input by name.29第29页
17、/共34页Assignment#1030第30页/共34页Assignment#11Define a dynamic singly linked list to store staffs information including id,name and salary.Please note that all the information should be input from the keyboard.Implement a function creat()to return the head pointer of the linked list;Implement a function
18、 named insert()to insert a staff into the linked list with the id from low to high;Implement a function named delete()to delete a staff with id n from the linked list;Implement a function named print()to print all the staff in the linked list to the standard output screen;Implement a function named
19、printToFile()to print all the staff in the linked list to a file.31第31页/共34页Assignment#12Define a book search card structure including book_name,author,publish_date,register_num and price.Input all the member variables of the structure and then output.Use the arrays of structures to store five students information including id,name and score,input the information from the keyboard,then output the average score of the students.32第32页/共34页Next AssignmentNoneThank you!33第33页/共34页34感谢您的观看。第34页/共34页
限制150内