This job requires see [https://edu.cnblogs.com/campus/nenu/2019fall/homework/5523]
1. familiar with the command line and console
And the application is assumed that there a.exe b.txt file in the current directory, and the auxiliary data stream in FIG what role the following text console commands Yes. (5 points)
a.exe < b.txt > c.txt
The content b as the input document input a.exe a result, the generation result obtained c.txt
Please made to develop applications in C d.exe, read commands from the console command line parameters, respectively, and print out the value of a, b, c in the console. Run the following example the effect of the form (6 points)
d.exe a=1 b=2 c=3
1
2
3
d.exe a=11 b=22 c=33
11
22
33
#include <stdio.h> int main(int argc, char *argv[]) { int a,b,c; sscanf(argv[1], "a=%d", &a); sscanf(argv[2], "b=%d", &b); sscanf(argv[3], "c=%d", &c); printf("%d\n\n",a); printf("%d\n\n",b); printf("%d",c); return 0; }
2.熟悉 测试用例
(2)在题目集 PAT (Basic Level) Practice (中文) 中任选3道题目完成。截图如下,要求包括1.红色对号、2.标号、3.用户名(此例中为 Young)。(30分)
(3) 1001 killed attractiveness of the (3n + 1) guess
For any positive integer n, if it is even, then it halved; if it is odd, then the (halved repeatedly been cut to such, in a final step to give certain. N- = 1. In Kharazi 1950 World Congress of mathematicians published on this conjecture, was the legendary Yale University teachers and students Qidong Yuan, desperately want to prove this seemingly silly naive proposition, students inadvertently result so much noise studies, one only certificate (that someone He said it was a conspiracy, Kharazi was deliberately delaying the progress of American mathematics teaching and research ......
Our topic today is not evidence Minka Raz conjecture, but on any given positive integer not exceeding 1,000 n, simply count the number, how many steps (cut a few) need to get the n- = 1?
Key / difficulty: cut by half the number of compute cycles
Code:
#include <stdio.h> #include <stdlib.h> int main() { int a,b=0; scanf("%d",&a); while(a!=1){ if(a%2==0) { a=a/2; b++; } else { a=3*a+1; a=a/2; b=b+1; } } printf("%d",b); }
1006 change the format of the output integer
Let the letter B
to mean "one hundred", the letter S
represents "ten", used 12...n
to indicate the digit is not zero n
( < . 1 0), any change to the output format does not exceed a positive integer of 3 bits. For example, 234
it should be output BBSSS1234
, because it has two "hundred", 3 "ten", and 4 bits.
Key / difficulty: how to find a ten one hundred digital, and the digital output cycle
Code:
#include <stdio.h> #include <stdlib.h> int main() { int i,j,k; int n,a,b,c; while(scanf("%d",&n)!=EOF&&n<1000) { a=n/100; for(i=1;i<=a;i++) { printf("B"); } b=n/10%10; for(j=1;j<=b;j++) { printf("S"); } c=n%10; for(k=1;k<=c;k++) { printf("%d",k); } } }
#include<stdio.h> #include<string.h> int main() { char N[1000]; int temp,i,j; scanf("%s",N); int arr[10]={}; for(i=0;i<strlen(N);i++) { temp=N[i]-'0'; switch(temp) { case(0):arr[0]++;break; case(1):arr[1]++;break; case(2):arr[2]++;break; case(3):arr[3]++;break; case(4):arr[4]++;break; case(5):arr[5]++;break; case(6):arr[6]++;break; case(7):arr[7]++;break; case(8):arr[8]++;break; case(9):arr[9]++;break; } } for(j=0;j<10;j++) if(arr[j]>0) printf("%d:%d\n",j,arr[j]); return 0; }
(4) PSP (8 minutes)
In the same blog, a reference textbook on page 35 Table 2-2 and Table 2-3, PSP production stage table above three topics.
PSP stage classification table column 1, as a function, function 2, a test function and the like.
1 estimate your requirements expected for each function (and / or sub-functions) to spend time, fill in the form PSP stage, the time granularity minutes.
2 requires actual recording frequency statistics project takes time, fill in the form PSP stage, the time required granularity minutes.
Comparative claim 1 and claim 3 in claim 2, the gap between each time spent analyze the causes.