#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int num;
scanf("%d",&num);
printf("2049%04d\n",num);
scanf("%d",&num);
printf("2049%04d\n",num);
scanf("%d",&num);
printf("2049%04d\n",num);
return 0;
}
![]()
1 #include <iostream>
2
3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
4
5 int main(int argc, char** argv) {
6 int x=1234;
7 float f = 123.456;
8 double m = 123.456;
9 char ch = 'a';
10 char a[] = "你好,世界";
11
12 int y=3, z=4;
13
14 printf("%d ,%d\n", y, z);
15 printf("y=%d, z=%d\n", y, z);
16 printf("%8d,%2d\n", x, x);
17 printf("%f, %8d, %8.1f, %0.2f, %.2e\n", f, f, f, f,f);
18 printf("%lf\n", m);
19 printf("%c\n", ch);
20 printf("%s\n%15s\n%10.5s\n%2.5s\n%.3s\n", a, a, a, a, a);
21
22 return 0;
23 }
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
double x,y;
char c1,c2,c3;
int a1,a2,a3;
scanf("%1d%1d%1d",&a1,&a2,&a3);
printf("%d,%d,%d\n", a1, a2, a3);
scanf("%c%c%c",&c1,&c2,&c3);
printf("%c%c%c\n", c1, c2, c3);
scanf("%lf,%lf",&x,&y);
printf("%f,%lf\n",x,y);
return 0;
}
![]()
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
char ans1, ans2;
printf("复习了没?(输入y或Y表示复习了,输入n或N表示没有复习):");
ans1 = getchar();
getchar(); //消除回车键对输入的影响
printf("\n动手敲代码了吗?(输入y或Y表示敲了,输入n或N表示没有敲):");
ans2 = getchar();
if((ans1=='y'||ans1=='Y')&&(ans2=='y'||ans2=='Y'))
printf("\nROME CITY was not built in one single day.\n");
else
printf("\nROME CITY was not destoryed in one single day.\n");
return 0;
}
![]()
1 #include <iostream>
2
3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
4
5 int main(int argc, char** argv) {
6 char x;
7
8 x = getchar();
9
10 if(x<='9'&&x>='0')
11 printf("%c是数字字符\n",x);
12 else if((x<='z'&&x>='a')||(x<='Z'&&x>='A'))
13 printf("%c是字母字符\n",x);
14 else
15 printf("%c是其他字符\n",x);
16
17 return 0;
18 }
1 #include <iostream>
2 #include <math.h>
3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
4
5 int main(int argc, char** argv) {
6 int n,s,q;
7 while(1){
8
9 scanf("%d",&n);
10 q = pow(2,n);
11 s = 2*(1-q)/(1-2)+1;
12 printf("n=%d时,sum=%d\n",n,s);
13 }
14 return 0;
15 }
1 #include <iostream>
2 #include <math.h>
3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
4
5 int main(int argc, char** argv) {
6 int col, line, n, m;
7 line = 1;
8 while(line <= 5){
9 n = 2*(6-line)-1;
10 m = (line-1)*4;
11
12 col = 1;
13 while(col <= m){
14 printf(" ");
15 col++;
16 }
17 col = 1;
18 while(col <= n){
19 printf(" O ");
20 col++;
21 }
22 printf("\n");
23 col = 1;
24 while(col <= m){
25 printf(" ");
26 col++;
27 }
28 col = 1;
29 while(col <= n){
30 printf("<H> ");
31 col++;
32 }
33 printf("\n");
34 col = 1;
35 while(col <= m){
36 printf(" ");
37 col++;
38 }
39 col = 1;
40 while(col <= n){
41 printf("I I ");
42 col++;
43 }
44 printf("\n");
45
46 line++;
47 }
48 return 0;
49 }