c语言-格式化输入和输出

img

#include "stdio.h"
void main()
{
    int a,b;
    float c;
    scanf("%d,%d,%f",&a,&b,&c);
    printf("%010o,%010d,%010.7f",a,b,c);
}
#include <stdio.h>
int main()
{
    int a,b;
    double f;
    scanf("%d,%d,%lf",&a,&b,&f);
    printf("%10d,%10d,%10lf\n",a,b,f);
    printf("0x%x\n",a);
    printf("%+d\n",b);
    printf("%.7lf",f);
    return 0;
} 

用printf就行。

/* printf example */
#include <stdio.h>

int main()
{
   printf ("Characters: %c %c \n", 'a', 65);
   printf ("Decimals: %d %ld\n", 1977, 650000L);
   printf ("Preceding with blanks: %10d \n", 1977);
   printf ("Preceding with zeros: %010d \n", 1977);
   printf ("Some different radices: %d %x %o %#x %#o \n", 100, 100, 100, 100, 100);
   printf ("floats: %4.2f %+.0e %E \n", 3.1416, 3.1416, 3.1416);
   printf ("Width trick: %*d \n", 5, 10);
   printf ("%s \n", "A string");
   return 0;
}