lcthw提交,做到了练习3,printf的输出格式
This commit is contained in:
parent
1ce1692d1b
commit
704504a2c1
|
@ -0,0 +1,12 @@
|
|||
#include <stdio.h>
|
||||
|
||||
/* This is a comment. */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int distance = 100;
|
||||
|
||||
// this is also a comment
|
||||
printf("You are %d miles away.\n", distance);
|
||||
|
||||
return 0;
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,12 @@
|
|||
#include <stdio.h>
|
||||
|
||||
/* T is a comment. */
|
||||
int main(int ac, char *gv[])
|
||||
{
|
||||
int distance = 100;
|
||||
|
||||
// this is also a comment
|
||||
printf("You are %d mes away.\nGood morning!\nGood afternoon!\nGood night!\nGood evening!\nIt's time for dinner!\n", distance);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
http://ewm.ptpress.com.cn:8085/preview?qrCode=qr2018001476&verified=true
|
|
@ -0,0 +1,6 @@
|
|||
CFLAGS=-Wall -g
|
||||
|
||||
all: clean ex1
|
||||
|
||||
clean:
|
||||
rm -f ex1
|
|
@ -0,0 +1,12 @@
|
|||
#include <stdio.h>
|
||||
|
||||
/* This is a comment. */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int distance = 100;
|
||||
|
||||
// this is also a comment
|
||||
printf("You are %d miles away.\n", distance);
|
||||
|
||||
return 0;
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,12 @@
|
|||
#include <stdio.h>
|
||||
|
||||
/* T is a comment. */
|
||||
int main(int ac, char *gv[])
|
||||
{
|
||||
int distance = 100;
|
||||
|
||||
// this is also a comment
|
||||
printf("You are %d mes away.\nGood morning!\nGood afternoon!\nGood night!\nGood evening!\nIt's time for dinner!\n", distance);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
http://ewm.ptpress.com.cn:8085/preview?qrCode=qr2018001476&verified=true
|
|
@ -0,0 +1,12 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int age = 10;
|
||||
int height = 72;
|
||||
|
||||
printf("I am %d years old.\n", age);
|
||||
printf("I am %d inches tall.\n", height);
|
||||
|
||||
return 0;
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,31 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main ( void )
|
||||
{
|
||||
int smallInt = 12;
|
||||
int largeInt = (1024*1024*3)+(1024*2)+512+128+64+32+16+8+4+2+1;
|
||||
int negativeInt = -smallInt;
|
||||
unsigned anUnsigned = 130;
|
||||
|
||||
// the other code snippets go here.
|
||||
printf( " Unsigned Printf \n" );
|
||||
printf( " Base Base-8 Base-10 Base-16 BASE-16\n" );
|
||||
printf( " Name octal unsigned hexadeximal HEXIDECIMAL\n" );
|
||||
printf( " Specifier %%12o %%12u %%12x %%12X \n" );
|
||||
printf( " [%12o] [%12u] [%12x] [%12X]\n" ,
|
||||
smallInt , smallInt, smallInt, smallInt );
|
||||
printf( " [%12o] [%12u] [%12x] [%12X]\n\n" ,
|
||||
largeInt , largeInt , largeInt , largeInt );
|
||||
printf( " [%12o] [%12u] [%12x] [%12X]\n\n" ,
|
||||
anUnsigned , anUnsigned , anUnsigned , anUnsigned );
|
||||
|
||||
printf( " Specifier %%#o %%#u %%#x %%#X\n" );
|
||||
printf( " [%#12o] [%12u] [%#12x] [%#12X]\n" ,
|
||||
smallInt , smallInt , smallInt , smallInt );
|
||||
printf( " [%#12o] [%12u] [%#12x] [%#12X]\n" ,
|
||||
largeInt , largeInt, largeInt , largeInt );
|
||||
printf( " [%#12o] [%12u] [%#12x] [%#12X]\n\n" ,
|
||||
anUnsigned , anUnsigned , anUnsigned , anUnsigned );
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main ( void )
|
||||
{
|
||||
int smallInt = 12;
|
||||
int largeInt = (1024*1024*3)+(1024*2)+512+128+64+32+16+8+4+2+1;
|
||||
int negativeInt = -smallInt;
|
||||
unsigned anUnsigned = 130;
|
||||
|
||||
// the other code snippets go here.
|
||||
}
|
Loading…
Reference in New Issue